- 帖子
- 3
- 精华
- 0
- 积分
- 11
- 阅读权限
- 10
- 注册时间
- 2020-1-27
- 最后登录
- 2020-1-28
|
代码如下:
# _*_ coding:utf-8 _*_
from urllib import request
import json
from city import city
cityname = input('你想查哪个城市的天气?\n')
citycode = city.get(cityname)
if citycode :
url = ('http://www.weather.com.cn/data/cityinfo/%s.html'%citycode)
content = request.urlopen(url).read()
print(content.decode('utf8'))
我的问题是爬取的结果有,但是和实际天气不对呀
你想查哪个城市的天气?
广州
{"weatherinfo":{"city":"广州","cityid":"101280101","temp1":"26℃","temp2":"29℃","weather":"阵雨转暴雨","img1":"n3.gif","img2":"d10.gif","ptime":"18:00"}}
实际广州的天气不是这样的!!!
|
|