気になるニュースは?
Pythonで面白そうなライブラリがあったので、触ってみた。
「GoogleNews - PyPI」というやつで、Googleニュースの記事を気になるカテゴリー
で収集するのに持って来い!ってやつ。
使い方は、[GoogleNews · PyPI]で確認してや。
こんな感じで取得や。
# -*- coding: utf-8 -*-
# 主要ニュース取得
from GoogleNews import GoogleNews
#検索したいニュースをkensakuに設定
for ke in kensaku:
print(f"-----------------{ke}-------------\n")
googlenews.get_news(ke)
googlenews.search(ke)
print(f'ニュース数:{googlenews.total_count()}本')
res = googlenews.results()
for n in res:
title = n.get("title")
link = n.get("link")
else:
pass
print(f"■{title}\n{str(link)}\n")
googlenews.clear()