예제 #1
0
func fetch_entries(feds []meta.Feed, done chan<- int) {
	fmt.Println("fetch entries", len(feds))
	curl := d.DefaultCurl()
	for _, feed := range feds {
		rsfile, _, _, err := curl.Download(feed.Link)
		fmt.Println(rsfile, err)
		if err != nil {
			fmt.Println(err)
			continue
		}
		f, entries, err := feeds.NewFeed(rsfile, feed.Link)
		if err != nil {
			fmt.Println(feed.Link, len(entries), err)
			feeds.NewFeedOperator().Disable(feed.Link, true)
		} else {
			fmt.Println(f.Title, len(entries))
		}

		if err == nil {
			ins, _ := feeds.NewEntryOperator().Save2(entries)
			fmt.Println(len(ins), feed.Link)
		}

	}
	done <- 0
}
예제 #2
0
func main() {
	defer catch_panic()
	flag.Parse()
	if len(*uri) == 0 {
		panic(errors.New("usage: subscribe --uri http://xome.rss2.xml"))
	}
	rsfile, _, _, _ := d.DefaultCurl().Download(*uri) //document.FetchUrl2(*uri)
	log.Println(rsfile)
	ch, _, _ := feeds.NewFeed(rsfile, *uri)
	log.Println(ch)
	feeds.NewFeedOperator().Upsert(ch)
}
예제 #3
0
func main() {
	c, items, _ := feeds.NewFeed(rssfile, base_url)
	fmt.Println(c)
	for _, item := range items {
		fmt.Println(item.Title)
	}
	fo := feeds.NewFeedOperator()
	fo.Upsert(c)
	x, _ := fo.Find("http://fulltextrssfeed.com/www.infzm.com/rss/home/rss2.0.xml")
	fmt.Println(x)

	eo := feeds.NewEntryOperator()
	eo.Save(items)
	//	feeds.InsertChannel(c)
	//	test_db(items)
}
예제 #4
0
func main() {
	defer recover_panic()
	flag.Parse()
	if len(*uri) == 0 {
		fmt.Println(errors.New("entry_fetcher --uri http://feeds.feedburner.com/chinadigitaltimes/ywgz"))
		return
	}
	log.Println("fetching", *uri)
	rsfile, _, _, _ := d.DownloadFile(*uri)
	log.Println("fetch url to ", rsfile)

	f, entries, err := feeds.NewFeed(rsfile, *uri)
	log.Println(f, len(entries), err)

	feeds.NewEntryOperator().Save(entries)

}
예제 #5
0
func subscribe_rss2(w http.ResponseWriter, r *http.Request) {
	defer func() {
		if err := recover(); err != nil {
			http.Error(w, err.(error).Error(), http.StatusBadGateway)
			fmt.Println(err)
		}
	}()

	r.ParseForm()
	url := r.FormValue("url")
	fmt.Println("fetching ", url)
	rss_file, _, _, _ := htmldoc.DefaultCurl().Download(url)
	fmt.Println("rss-file", rss_file)
	channel, _, _ := feeds.NewFeed(rss_file, url)
	feeds.NewFeedOperator().Upsert(channel)

	write_json(w, channel)
}