Documentation
¶
Index ¶
- Constants
- Variables
- type GNews
- func (g *GNews) ConvertToOriginalLinks(items []*News)
- func (g *GNews) GetFilteredItems(items []*News) []*News
- func (g *GNews) GetLocationNews(location string) ([]*News, error)
- func (g *GNews) GetTopNews() ([]*News, error)
- func (g *GNews) GetTopicNews(topic string) ([]*News, error)
- func (g *GNews) SearchNews(query string) ([]*News, error)
- func (g *GNews) SetEndDate(endDate *time.Time) *GNews
- func (g *GNews) SetExcludeWebsites(excludeWebsites []string) *GNews
- func (g *GNews) SetLanguage(language string) *GNews
- func (g *GNews) SetLimit(limit int) *GNews
- func (g *GNews) SetLocation(location string) *GNews
- func (g *GNews) SetPeriod(period *time.Duration) *GNews
- func (g *GNews) SetProxy(proxy string) *GNews
- func (g *GNews) SetStartDate(startDate *time.Time) *GNews
- type News
Constants ¶
const ( // Topic TopicWorld string = "WORLD" TopicNation string = "NATION" TopicBusiness string = "BUSINESS" TopicTechnology string = "TECHNOLOGY" TopicEntertainment string = "ENTERTAINMENT" TopicSports string = "SPORTS" TopicScience string = "SCIENCE" TopicHealth string = "HEALTH" )
const ( LanguageEnglish = "en" LanguageIndonesian = "id" LanguageCzech = "cs" LanguageGerman = "de" LanguageSpanish = "es-419" LanguageFrench = "fr" LanguageItalian = "it" LanguageLatvian = "lv" LanguageLithuanian = "lt" LanguageHungarian = "hu" LanguageDutch = "nl" LanguageNorwegian = "no" LanguagePolish = "pl" LanguagePortugueseBrasil = "pt-419" LanguagePortuguesePortugal = "pt-150" LanguageRomanian = "ro" LanguageSlovak = "sk" LanguageSlovenian = "sl" LanguageSwedish = "sv" LanguageVietnamese = "vi" LanguageTurkish = "tr" LanguageGreek = "el" LanguageBulgarian = "bg" LanguageRussian = "ru" LanguageSerbian = "sr" LanguageUkrainian = "uk" LanguageHebrew = "he" LanguageArabic = "ar" LanguageMarathi = "mr" LanguageHindi = "hi" LanguageBengali = "bn" LanguageTamil = "ta" LanguageTelugu = "te" LanguageMalyalam = "ml" LanguageThai = "th" LanguageChineseSimplified = "zh-Hans" LanguageChineseTraditional = "zh-Hant" LanguageJapanese = "ja" LanguageKorean = "ko" )
Host Language
const ( LocationAustralia = "AU" LocationBotswana = "BW" LocationCanada = "CA" LocationEthiopia = "ET" LocationGhana = "GH" LocationIndia = "IN" LocationIndonesia = "ID" LocationIreland = "IE" LocationIsrael = "IL" LocationKenya = "KE" LocationLatvia = "LV" LocationMalaysia = "MY" LocationNamibia = "NA" LocationNewZealand = "NZ" LocationNigeria = "NG" LocationPakistan = "PK" LocationPhilippines = "PH" LocationSingapore = "SG" LocationSouthAfrica = "ZA" LocationTanzania = "TZ" LocationUganda = "UG" LocationUnitedKingdom = "GB" LocationUnitedStates = "US" LocationZimbabwe = "ZW" LocationCzechRepublic = "CZ" LocationGermany = "DE" LocationAustria = "AT" LocationSwitzerland = "CH" LocationArgentina = "AR" LocationChile = "CL" LocationColombia = "CO" LocationCuba = "CU" LocationMexico = "MX" LocationPeru = "PE" LocationVenezuela = "VE" LocationBelgium = "BE" LocationFrance = "FR" LocationMorocco = "MA" LocationSenegal = "SN" LocationItaly = "IT" LocationLithuania = "LT" LocationHungary = "HU" LocationNetherlands = "NL" LocationNorway = "NO" LocationPoland = "PL" LocationBrazil = "BR" LocationPortugal = "PT" LocationRomania = "RO" LocationSlovakia = "SK" LocationSlovenia = "SI" LocationSweden = "SE" LocationVietnam = "VN" LocationTurkey = "TR" LocationGreece = "GR" LocationBulgaria = "BG" LocationRussia = "RU" LocationUkraine = "UA" LocationSerbia = "RS" LocationUnitedArabEmirates = "AE" LocationSaudiArabia = "SA" LocationLebanon = "LB" LocationEgypt = "EG" LocationBangladesh = "BD" LocationThailand = "TH" LocationChina = "CN" LocationTaiwan = "TW" LocationHongKong = "HK" LocationJapan = "JP" LocationRepublicOfKorea = "KR" )
Geographic Location
Variables ¶
var ( TopicMap = map[string]string{ TopicWorld: "w", TopicNation: "n", TopicBusiness: "b", TopicTechnology: "t", TopicEntertainment: "e", TopicSports: "s", TopicScience: "snc", TopicHealth: "m", } )
Functions ¶
This section is empty.
Types ¶
type GNews ¶
type GNews struct {
// contains filtered or unexported fields
}
GNews is the main struct
func NewGNews ¶
func NewGNews() *GNews
NewGNews creates a new GNews instance Language and location are optional If you don't specify them, the default language and location will be used The default language is traditional Chinese The default location is TW Language is the language of the news (e.g. en, fr, de, etc.) Location is the location of the news (e.g. US, FR, DE, etc.)
func (*GNews) ConvertToOriginalLinks ¶ added in v1.1.0
ConvertToOriginalLinks converts the google news links to original links
func (*GNews) GetFilteredItems ¶ added in v1.1.0
getFilteredItems filters the items
func (*GNews) GetLocationNews ¶
GetLocationNews gets the news by location
func (*GNews) GetTopicNews ¶
GetNewsByTopic gets the news by topic
func (*GNews) SearchNews ¶
Search searches the news
func (*GNews) SetEndDate ¶
SetEndDate sets the end date of the news If you want to set a custom period, use SetPeriod
func (*GNews) SetExcludeWebsites ¶
SetExcludeWebsites sets the websites to exclude from the results
func (*GNews) SetLanguage ¶
SetLanguage sets the language of the news
func (*GNews) SetLocation ¶
SetLocation sets the location of the news
func (*GNews) SetPeriod ¶
SetPeriod sets the period of the news Available periods are: 1h, 1d, 7d, 30d, 1y If you want to set a custom period, use SetStartDate and SetEndDate
type News ¶
type News struct { Title string Description string Link string Links []string Content string Published string PublishedParsed *time.Time Updated string UpdatedParsed *time.Time GUID string ImageURL string Categories []string }