コード例 #1
0
ファイル: main.py プロジェクト: AlexGustafsson/irc-news-bot
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"])
コード例 #2
0
def main():
    print("hello world")

    gn = GoogleNews()

    top = gn.top_news()

    for i in range(10):
        print(top['entries'][i])

    return 0
コード例 #3
0
ファイル: helper.py プロジェクト: Bruck1701/NewsDiscordBot
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
コード例 #4
0
from pygooglenews import GoogleNews

gn = GoogleNews(lang='pt')
top = gn.top_news()

for item in top['entries']:
    print(item.title)