googleNews

package module
v0.0.0-...-688f25b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleNews

type GoogleNews struct {
	Lang   string
	Region string
	// contains filtered or unexported fields
}

A GoogleNews struct represents a connection to google news

If you want to initialize a GoogleNews client, please use googleNews.New()

func New

func New(lang, region string) *GoogleNews

New returns a new GoogleNews Client

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

func (c *GoogleNews) SearchPeriod(searchTerm string, period string) (*[]models.Article, error)

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

func (c *GoogleNews) SearchTopic(topic models.Topic) (*[]models.Article, error)

SearchTopic queries the /topics endpoint for the given topic

func (*GoogleNews) TopNews

func (c *GoogleNews) TopNews() (*[]models.Article, error)

TopNews returns the top articles based on the configured region and language

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL