[問題] 網頁抓不下來
各位前輩大大好:
我在練習抓天氣網站的資料,可是照著API教學卻出現錯誤訊息,
請大大幫忙看一下是哪邊做錯,感謝~
程式碼:
location = ' '.join(sys.argv[1:])
# Download the JSON data from OpenWeatherMap.org's API.
url = 'http://api.openweathermap.org/data/2.5/forecast/daily?q=%s&cnt=3' %
(location)
response = requests.get(url)
response.raise_for_status()
錯誤訊息:
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:
http://api.openweathermap.org/data/2.5/forecast/daily?q=Taipei&cnt=3
天氣網站API設定教學:
https://openweathermap.org/forecast16
Examples of API calls: Call 7 days forecast by city name
api.openweathermap.org/data/2.5/forecast/daily?q=London&cnt=7
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.177.123.190 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1560005445.A.0B6.html
→
06/08 23:30,
6年前
, 1F
06/08 23:30, 1F
→
06/08 23:52,
6年前
, 2F
06/08 23:52, 2F
→
06/09 01:04,
6年前
, 3F
06/09 01:04, 3F
喔喔,謝謝各位大大釋疑,還真的要註冊拿key才能用
https://openweathermap.org/appid
※ 編輯: purplvampire (180.177.123.190 臺灣), 06/09/2019 10:30:06
Python 近期熱門文章
PTT數位生活區 即時熱門文章