未来七天-天气API
- 通过城市名称获得天气数据,json格式返回
http://wthrcdn.etouch.cn/weather_mini?city=北京
- 通过城市代码获得天气数据,json格式返回
http://wthrcdn.etouch.cn/weather_mini?citykey=101010100
返回json数据格式如下:
{"desc":"OK",
"status":1000,
"data":{
"wendu":"22",
"ganmao":"风较大,较易发生感冒,注意防护。",
"forecast":[
{"fengxiang":"北风","fengli":"5-6级","high":"高温 24℃","type":"晴","low":"低温 11℃","date":"3日星期六"},
{"fengxiang":"北风","fengli":"4-5级","high":"高温 19℃","type":"晴","low":"低温 8℃","date":"4日星期日"},
{"fengxiang":"无持续风向","fengli":"微风","high":"高温 21℃","type":"晴","low":"低温 9℃","date":"5日星期一"},
{"fengxiang":"无持续风向","fengli":"微风","high":"高温 21℃","type":"多云","low":"低温 10℃","date":"6日星期二"},
{"fengxiang":"无持续风向","fengli":"微风","high":"高温 24℃","type":"晴","low":"低温 12℃","date":"7日星期三"},
{"fengxiang":"无持续风向","fengli":"微风","high":"高温 23℃","type":"晴","low":"低温 11℃","date":"8日星期四"}],
"yesterday":{"fl":"微风","fx":"无持续风向","high":"高温 23℃","type":"晴","low":"低温 12℃","date":"2日星期五"},
"aqi":"59",
"city":"北京"}
}
- 通过城市名称获得天气数据,xml格式返回
http://wthrcdn.etouch.cn/WeatherApi?city=北京
- 通过城市代码获得天气数据,xml格式返回
http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100
XML格式返回内容更加完整
96年起各地历史天气查询
url = 'https://www.wunderground.com/history/airport/ZBAA/{}/{}/{}/DailyHistory.html?req_city={}'.format(year, month, day, cityname)
由此页面返回内容结合html页面parser,解析出需要内容