Inspired by pygooglenews
A golang based wrapper of the Google News RSS feed.
Top stories, topic related news feeds, geolocation news feed, and an extensive full text search feed.
This work is more of a collection of all things I could find out about how Google News functions.
go get github.com/spl0i7/gogooglenews
googleNews, err := gogooglenews.NewGoogleNews(gogooglenews.GoogleNewsOpt{
Lang: "en",
Country: "IN",
})
news, err = googleNews.TopNews()
news, err = googleNews.TopicHeadlines("BUSINESS")
news, err = googleNews.GeoHeadlines("bangalore")
to := time.Now()
from := to.AddDate(0, 0, -10)
news, err = googleNews.Search("Bitcoin", &from, &to)
If you make frequent calls to the rss service, its very much possible that Google might blacklist your IP.
To bypass this, ideally you should be making requests behind a proxy. To use a proxy pass the http client in options as following.
proxyUrl, err := url.Parse("http://proxyIp:proxyPort")
myClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
googleNews, err := gogooglenews.NewGoogleNews(gogooglenews.GoogleNewsOpt{
Lang: "en",
Country: "IN",
HttpClient: myClient
})