且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法从 Python 中的 Beautifulsoup 中获取值

更新时间:2022-05-05 23:02:31

使用与 page 相同的 API 来获取 json 来填充这些值.请注意传递给 API 的查询字符串构造.

Use the same API as page does to get json to populate those values. Notice the querystring construction passed to the API.

import requests

headers = {'Referer' : 'https://www.windguru.cz/station/219'}    
r = requests.get('https://www.windguru.cz/int/iapi.php?q=station_data_current&id_station=219&date_format=Y-m-d%20H%3Ai%3As%20T&_mha=f4d18b6c', headers = headers).json()
print(r)
print(r['wind_max'])