webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

PythonでGoogleニュースのRSSフィードをJSON形式で返すライブラリ「GNews」をインストール

カテゴリ: Python【初歩から現場実務的なもの】

PythonでGoogleニュースのRSSフィードをJSON形式で返すライブラリ「GNews」のインストールについて解説しています。

GNews(https://github.com/ranahaani/GNews/)は、GoogleニュースのRSSフィードを検索し、JSON形式で返すAPIを提供しています。なお、記事全体を抜き出すこともできます。

■Python

今回のPythonのバージョンは、「3.6.8」を使用しています。(Windows10)(pythonランチャーでの確認)

■GNewsをインストールする

GNewsをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install gnews

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.6.8にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.6 -m pip install gnews

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting gnews

Downloading gnews-0.2.0-py3-none-any.whl (9.6 kB)

Requirement already satisfied: beautifulsoup4 in c:\users\user_\appdata\roaming\python\python36\site-packages (from gnews) (4.9.3)

Collecting feedparser

Downloading feedparser-6.0.8-py3-none-any.whl (81 kB)

|████████████████████████████████| 81 kB 741 kB/s

Requirement already satisfied: soupsieve>1.2 in c:\users\user_\appdata\roaming\python\python36\site-packages (from beautifulsoup4->gnews) (2.2.1)

Collecting sgmllib3k

Downloading sgmllib3k-1.0.0.tar.gz (5.8 kB)

Using legacy 'setup.py install' for sgmllib3k, since package 'wheel' is not installed.

Installing collected packages: sgmllib3k, feedparser, gnews

Running setup.py install for sgmllib3k ... done

Successfully installed feedparser-6.0.8 gnews-0.2.0 sgmllib3k-1.0.0

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、GNewsが正常にインストールされたことになります。

なお、今回はGNewsのバージョン0.2.0をインストールしました。