Пример #1
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)

}
Пример #2
0
func find_feeds(q string) (v feed_find_response, e error) {
	uri := "http://ajax.googleapis.com/ajax/services/feed/find?v=1.0&num=20&q=" + q
	f, _, _, e := document.DownloadFile(uri)
	if e != nil {
		fmt.Println(e)
		return
	}
	fmt.Println(f)
	lf, e := os.Open(f)
	if e != nil {
		fmt.Println(e)
		return
	}
	defer lf.Close()

	dec := json.NewDecoder(lf)
	e = dec.Decode(&v)
	fmt.Println(len(v.Data.Entries), e)
	return
}
Пример #3
0
func load_entries(q string) (v feed_load_response, e error) {
	uri := "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=20&q=" + q // "http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml"
	f, _, _, e := document.DownloadFile(uri)
	if e != nil {
		fmt.Println(e)
		return
	}
	fmt.Println(f)
	lf, e := os.Open(f)
	if e != nil {
		fmt.Println(e)
		return
	}
	defer lf.Close()

	dec := json.NewDecoder(lf)
	e = dec.Decode(&v)
	fmt.Println(v.Data.Feed.Title, e, v.Details)
	return
}