[問題] 網頁抓不下來

作者: purplvampire (阿修雷)   2019-06-08 22:50:38
各位前輩大大好:
我在練習抓天氣網站的資料,可是照著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
作者: vi000246 (Vi)   2019-06-08 23:30:00
可能要收費吧 你去看文件 應該是沒取得授權
作者: InfinityGate (小鳥)   2019-06-08 23:52:00
API KEY...
作者: Hsins (翔)   2019-06-09 01:04:00
Unauthorized 不就很明顯ㄌ?

Links booklink

Contact Us: admin [ a t ] ucptt.com