# 休憩がてらみるサイト - [ロケットニュース](https://rocketnews24.com) - [Gadget Gate](https://gadget.phileweb.com/) - [Gigazine](https://gigazine.net) - [すする音は外国人にとって不愉快???](https://rocketnews24.com/2024/02/01/2165824/) - [フローラルの香りの石鹸を使うと蚊に刺されやすくなる](https://gigazine.net/news/20230512-soaps-floral-attract-mosquitoes/) - [飛行機がどこ飛んでるかみれるマップ](https://ja.flightaware.com/live/) ![絶望的なとことんでる飛行機いっぱいおるやん](https://hackmd.io/_uploads/Sy_8GRUU3.png) - [気象庁公式(APIとしては非公式)API1(大阪府の天気)](https://www.jma.go.jp/bosai/forecast/data/forecast/270000.json) - [気象庁公式(APIとしては非公式)API2(大阪府の天気)](https://www.jma.go.jp/bosai/forecast/data/overview_forecast/270000.json) - [世界人口変動](https://www.worldometers.info/world-population/) - [うまそう](https://gigazine.net/news/20230605-acecook-taratarasitenzyaneyo/) - [ニンニクのにおいについて](https://gigazine.net/news/20230605-garlic-breath/) - [ともとこれしたい](https://gigazine.net/news/20230621-nintendo-direct-super-mario-bros-wonder/) - [【chatGPT】そんなこととは思っていた](https://gigazine.net/news/20230621-chatgpt-accounts-dark-web-marketplaces/) - [【Linuxバグ発見】どうやったん?](https://gigazine.net/news/20230619-loop-linux-292612-times/) - [【藤井さん用】動物などの顔を動かすソフト](https://gigazine.net/news/20230627-drag-your-gan/) - [iphoneのパスワードわからんくなったら、一回も試してなかったら業者やと解除できるとか聞いたことある](https://gigazine.net/news/20230629-break-voice-authentication/) - [CSS_hoverの方法](https://zenn.dev/kagan/articles/css-hover-style) - [リアルタイムで雷が落ちたところをみれるサイト](https://map.blitzortung.org/#11.53/34.6965/135.5215) - [雑学](https://10zatsugaku.info/) - [名字人口](https://www.dmuchgis.com/myojimap/#) - [なぞなぞ1](https://nazonazo.nihonsimondai.com/) - [なぞなぞ2](http://nazo-nazo.com/sp/cat397/post-20.html) - [賃貸探し](https://rocketnews24.com/2024/02/13/2171894/) --- <span>get-weather.py</span> ```# !pip install requests import requests import json import datetime location = "大阪" location_json = { "滋賀":250000, "京都":260000, "大阪":270000, "兵庫":280000, "奈良":290000, "和歌山":300000, } LINE_TOKEN = "" def main(): # 入力された場所の予報区コードを取得 location_code = location_json[location] # 入力された場所の天気を取得 url = "https://www.jma.go.jp/bosai/forecast/data/forecast/"+ str(location_code) + ".json" today_weather_json = requests.get(url=url).json() # 取得したデータから天気コードを抜粋 today_weather_code = today_weather_json[0]['timeSeries'][0]['areas'][0]['weatherCodes'][0] # 取得した天気コードをweatherCodes.jsonに設定されている文字に変換 weather_codes_json = json.load(open('weatherCodes.json','r',encoding="utf-8")) today_weather = weather_codes_json[str(today_weather_code)][3].replace('後','のち') # get_location() message = generate_message(today_weather) # 現在地取得(API使用) # def get_location(): # geo_request_url = "https://get.geojs.io/v1/ip/geo.json" # geo_data = requests.get(geo_request_url).json() # print(geo_data['latitude']) # print(geo_data['longitude']) def generate_message(weather): print(weather) message = "" if len(weather) == 1: print("1日中天気が変わらない") message = weather else: print("1日で天気が変わる") weather_before = weather[0] weather_after = "" if(weather[-1] == "雨"): if(weather[-2] == "雷"): weather_after = "雷雨" else: weather_after = "雨" else: weather_after = weather[-1] if "時々" in weather: message = weather_before + "時々" + weather_after elif "のち" in weather: message = weather_before + "のち" + weather_after print(message) def pop_message(message): # 発行されたトークン ACCESS_TOKEN = "" headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"} data = { "message": message } requests.post( "https://notify-api.line.me/api/notify", headers=headers, data=data, ) if __name__ == '__main__': main() ```