Documentation ¶
Index ¶
- Constants
- Variables
- func CleanHTML(content string) string
- func FetchNewsContent(link string) (string, error)
- func FormatDuration(duration time.Duration) string
- func GetFeedItems(client *http.Client, req *http.Request) ([]*gofeed.Item, error)
- func GetOriginalLink(sourceLink string) (string, error)
- func IsNewsApiLink(link string) bool
- func NewNewsApi(options ...NewsApiOption) *newsApi
- func ToSourceLinks(newsList []*News)
- type News
- type NewsApi
- type NewsApiOption
- type QueryOption
- func WithEndDate(endDate time.Time) QueryOption
- func WithLanguage(language string) QueryOption
- func WithLimit(limit int) QueryOption
- func WithLocation(location string) QueryOption
- func WithPeriod(period time.Duration) QueryOption
- func WithStartDate(startDate time.Time) QueryOption
- func WithoutDuration() QueryOption
- func WithoutEndDate() QueryOption
- func WithoutPeriod() QueryOption
- func WithoutStartDate() QueryOption
Constants ¶
View Source
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" )
View Source
const ( // Africa LocationBotswana = "BW" LocationEthiopia = "ET" LocationGhana = "GH" LocationKenya = "KE" LocationNamibia = "NA" LocationNigeria = "NG" LocationSouthAfrica = "ZA" LocationTanzania = "TZ" LocationUganda = "UG" LocationZimbabwe = "ZW" // Asia LocationIndia = "IN" LocationIndonesia = "ID" LocationIsrael = "IL" LocationMalaysia = "MY" LocationPakistan = "PK" LocationPhilippines = "PH" LocationSingapore = "SG" LocationVietnam = "VN" LocationTurkey = "TR" LocationBangladesh = "BD" LocationThailand = "TH" LocationChina = "CN" LocationTaiwan = "TW" LocationHongKong = "HK" LocationJapan = "JP" LocationRepublicOfKorea = "KR" // Europe LocationAustralia = "AU" LocationIreland = "IE" LocationLatvia = "LV" LocationUnitedKingdom = "GB" LocationCzechRepublic = "CZ" LocationGermany = "DE" LocationAustria = "AT" LocationSwitzerland = "CH" LocationBelgium = "BE" LocationFrance = "FR" LocationItaly = "IT" LocationLithuania = "LT" LocationHungary = "HU" LocationNetherlands = "NL" LocationNorway = "NO" LocationPoland = "PL" LocationPortugal = "PT" LocationRomania = "RO" LocationSlovakia = "SK" LocationSlovenia = "SI" LocationSweden = "SE" LocationGreece = "GR" LocationBulgaria = "BG" LocationRussia = "RU" LocationUkraine = "UA" LocationSerbia = "RS" // North America LocationCanada = "CA" LocationMexico = "MX" LocationUnitedStates = "US" // South America LocationArgentina = "AR" LocationChile = "CL" LocationColombia = "CO" LocationCuba = "CU" LocationPeru = "PE" LocationVenezuela = "VE" // Middle East LocationUnitedArabEmirates = "AE" LocationSaudiArabia = "SA" LocationLebanon = "LB" LocationEgypt = "EG" )
Geographic Location
View Source
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" )
View Source
const (
MaxSearchResults = 100
)
Variables ¶
View Source
var ( ErrEmptyQuery = errors.New("query cannot be empty") ErrEmptyTopic = errors.New("topic cannot be empty") ErrInvalidTopic = errors.New("invalid topic") ErrEmptyLocation = errors.New("location cannot be empty") ErrFailedToGetNewsContent = errors.New("failed to get news content") ErrEmptyLink = errors.New("link cannot be empty") )
View Source
var ( USER_AGENTS = []string{}/* 184 elements not displayed */ RandomUserAgent = func() string { return USER_AGENTS[rand.Intn(len(USER_AGENTS))] } )
View Source
var (
GOOGLE_NEWS_REGEX = `^http(s)?://(www.)?news.google.com*`
)
View Source
var ( TopicMap = map[string]string{ TopicWorld: "w", TopicNation: "n", TopicBusiness: "b", TopicTechnology: "t", TopicEntertainment: "e", TopicSports: "s", TopicScience: "snc", TopicHealth: "m", } )
Functions ¶
func FetchNewsContent ¶
FetchNewsContent fetches the content of the news
func FormatDuration ¶
func GetFeedItems ¶
GetFeedItems gets feed items from a request
func GetOriginalLink ¶
GetOriginalLink gets the original link
func IsNewsApiLink ¶
IsNewsApiLink checks if a link is a news api link
func NewNewsApi ¶
func NewNewsApi(options ...NewsApiOption) *newsApi
func ToSourceLinks ¶
func ToSourceLinks(newsList []*News)
ToSourceLinks converts the google news links to original links
Types ¶
type NewsApiOption ¶
type NewsApiOption func(*newsApi)
func WithProxy ¶
func WithProxy(proxy *url.URL) NewsApiOption
func WithoutProxy ¶
func WithoutProxy() NewsApiOption
type QueryOption ¶
type QueryOption func(*newsApi)
func WithEndDate ¶
func WithEndDate(endDate time.Time) QueryOption
func WithLanguage ¶
func WithLanguage(language string) QueryOption
func WithLimit ¶
func WithLimit(limit int) QueryOption
func WithLocation ¶
func WithLocation(location string) QueryOption
func WithPeriod ¶
func WithPeriod(period time.Duration) QueryOption
func WithStartDate ¶
func WithStartDate(startDate time.Time) QueryOption
func WithoutDuration ¶
func WithoutDuration() QueryOption
func WithoutEndDate ¶
func WithoutEndDate() QueryOption
func WithoutPeriod ¶
func WithoutPeriod() QueryOption
func WithoutStartDate ¶
func WithoutStartDate() QueryOption
Click to show internal directories.
Click to hide internal directories.