README
¶
googleNews
A go wrapper for the google news rss feed
Functionality
TopNews()
Returns the top news based on the configured region and language
Search(), SearchPeriod(), SearchTimeFrame()
Enables searching for specific keywords and retrieving articles for a given period (last 7 days) or a custom time frame (before, after)
SearchTopics()
Returns the latest articles for topics such as Business, Health, etc
Installation
go get github.com/TomRomeo/googleNews
Getting started
func main() {
gn := googleNews.New("en", "US")
articles, err := gn.TopNews()
if err != nil {
log.Fatal(err)
}
log.Println("Current top news for your region:")
for _, art := range *articles {
log.Println(art.Title)
}
}
Documentation
¶
Index ¶
- type GoogleNews
- func (c *GoogleNews) Search(searchTerm string) (*[]models.Article, error)
- func (c *GoogleNews) SearchPeriod(searchTerm string, period string) (*[]models.Article, error)
- func (c *GoogleNews) SearchTimeframe(searchTerm string, after, before string) (*[]models.Article, error)
- func (c *GoogleNews) SearchTopic(topic models.Topic) (*[]models.Article, error)
- func (c *GoogleNews) TopNews() (*[]models.Article, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoogleNews ¶
A GoogleNews struct represents a connection to google news
If you want to initialize a GoogleNews client, please use googleNews.New()
func (*GoogleNews) Search ¶
func (c *GoogleNews) Search(searchTerm string) (*[]models.Article, error)
Search let's you retrieve articles from a custom search query
func (*GoogleNews) SearchPeriod ¶
SearchPeriod enables searching for a query in a given time period example: period: 7d - search query in articles of the last 7 days
func (*GoogleNews) SearchTimeframe ¶
func (c *GoogleNews) SearchTimeframe(searchTerm string, after, before string) (*[]models.Article, error)
SearchTimeframe is similar to SearchPeriod, making it possible to search between two dates dates should have the format: 2020-06-02
func (*GoogleNews) SearchTopic ¶
SearchTopic queries the /topics endpoint for the given topic