TUIでBBCの天気情報が確認できるbbc_weather_scraper

BBCの天気情報を取得してTUIで表示するbbc_weather_scraperというツールを知ったので少し試してみました.
BBCの天気情報は細かな土地には対応していませんが全世界の天気が確認でき,onion siteもあって便利です.

導入
$ git clone https://github.com/leonmavr/bbc_weather_scraper
$ cd bbc_weather_scraper
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
error1
$ ./scraper.py
Traceback (most recent call last):
  File "/home/matoken/src/bbc_weather_scraper/./scraper.py", line 3, in <module>
    from hourly import fmt_day_hourly
  File "/home/matoken/src/bbc_weather_scraper/hourly.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

requests が足りないようなので,requirements.txt に requests を追加して pip install -r requirements.txt を再実行.

error2
$ ./scraper.py
Traceback (most recent call last):
  File "/home/matoken/src/bbc_weather_scraper/./scraper.py", line 8, in <module>
    from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'

今度は pynput が足りないようなので requirements.txt に追加して pip install -r requirements.txt を再実行.

これで動作するようになりました.

修正後の requirements.txt
$ git diff
diff --git a/requirements.txt b/requirements.txt
index b6942e8..9172c97 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,5 @@
 beautifulsoup4==4.12.3
 wcwidth==0.2.13
 geopy
+requests
+pynput

引数なしで実行すると city_ids.dat 内から近くであろう場所が選ばれます.
KagoshimaなどBBCにはあるけれどこのリストにない場所の場合以下のページから探してURLの最後のIDをメモします.Kagoshimaの場合, URLは https://www.bbc.com/weather/6300348 で,IDは 6300348 です.

city_ids.dat に名前とこのIDを追加します.

Kagoshima: 6300348

引数に名前を書くことで指定した場所が開けます.

$ ./scraper.py Kagoshima

更に緯度,経度を追加することもできます.

Kagoshima: 6300348: 31.801837, 130.719404

自分の環境では物理的にはKagoshimaが近いのですが,Tokyoになってしまいます.
これは回線によるのだと思います.

起動したらwasdで日にちを移動,fで詳細を開けます.xで戻り,qで終了です.

動作するようになったのですが,何もしなくても細かくフラッシュされて見づらいです.
demoではそんなことはなさそうなのでなにかの環境が悪いのかもしれません.

環境
$ git log --pretty=oneline -1
e648ad41b5d192ff2e21bebb18feece7981ef4de (HEAD -> master, origin/master, origin/HEAD) Add requirements
$ python --version
Python 3.13.3
$ dpkg-query -W python3 python3-venv python3-pip
python3 3.13.3-1
python3-pip     25.1+dfsg-1
python3-venv    3.13.3-1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
Codename:       trixie
$ arch
x86_64

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です