def handle_top(irc: IRC, google_news: GoogleNews, target: str) -> None: """Handle a search request.""" irc.send_message(target, "Working on it") logger.info("Fetching top news") news = google_news.top_news() for entry in news["entries"][:5]: irc.send_message(target, entry["title"])
def main(): print("hello world") gn = GoogleNews() top = gn.top_news() for i in range(10): print(top['entries'][i]) return 0
def get_articles(lang, country, number_articles): gn = GoogleNews(lang.lower(), country.upper()) gn.BASE_URL = gn.BASE_URL + "?hl={}&gl={}".format(gn.lang, gn.country) top_news = gn.top_news() entries = top_news["entries"] if number_articles < len(entries): entries = entries[:number_articles] return entries
from pygooglenews import GoogleNews gn = GoogleNews(lang='pt') top = gn.top_news() for item in top['entries']: print(item.title)