Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Unofficial JMA weather forecast API wrapper in Python
気象庁天気予報データの非公式Pythonラッパー
2022-05-27時点のAPIに対応
pip3 install aoirint_jmapy
from aoirint_jmapy import JmaApi, Telops
# UserAgentに含めるため、あなたのアプリケーション名、バージョンを設定することを推奨
# UserAgentは次のようになります: MyWeatherApp 0.1.0 / aoirint_jmapy 20220527.4
# アプリケーションを一般に配布する場合、不具合等により不特定多数の端末から
# 気象庁のサーバに負荷をかけることがないように、自分でキャッシュサーバを立てること等を推奨
# jma_url以下のパスを揃えると切り替えできる
jma = JmaApi(
jma_url='https://www.jma.go.jp',
app_name='MyWeatherApp',
app_version='0.1.0',
)
# 東京都
forecast = jma.forecast(area_id='130000')
print(forecast)
## 東京地方
print(forecast[0])
### 3日間予報
print(forecast[0].timeSeries[0])
### 週間予報
print(forecast[0].timeSeries[1])
### 3日間天気概況
overview_forecast = jma.overview_forecast(area_id='130000')
print(overview_forecast.text)
### 週間天気概況
overview_week = jma.overview_week(area_id='130000')
print(overview_week.text)
# WeatherCodeを対応するテキストにする(Third party contentsの項を参照)
weather_code = '101'
print(Telops[weather_code][3]) # 晴時々曇
# エリアリスト
area = jma.area()
## センターリスト(気象台リスト)
print(area.centers)
### 北海道地方: center_id=010100
#### 宗谷地方: area_id=011000
#### 上川・留萌地方: area_id=012000
print(area.centers['010100'])
### 関東甲信地方: center_id=010300
#### 東京都: area_id=130000
#### 神奈川県: area_id=140000
print(area.centers['010300'])
「晴」「曇後雨」などのテキストは、API中でweatherCode
という数値IDで識別されます。
この数値IDに対応するテキストはAPIから取得できず、JavaScriptコードとして埋め込まれています。
利便性のため、この辞書をダンプしたものをライブラリに同梱し、コード中から参照できるようにしています。
aoirint_jmapy/static/const_telops.json
https://www.jma.go.jp/bosai/forecast/を開く。 開発者ツールで以下を実行、出力をコピーして貼り付けする。
console.log(JSON.stringify(Forecast.Const.TELOPS))
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
pip3 install pip-tools
pip-compile requirements.in
pip-compile requirements.test.in
# Download some JMA API response for test
./get_testdata.sh
pip3 install -r requirements.test.txt
mypy aoirint_jmapy/
pytest tests/
GitHub Releaseを作成するとGitHub Actionsにより自動でPyPIにリリースされる。
FAQs
Unofficial JMA weather forecast API wrapper in Python
We found that aoirint-jmapy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.