import requests, json
url = 'http://t.weather.sojson.com/api/weather/city/101110807'
response = requests.get(url)
# d = response.content.decode()
d = response.json()
print(d)
dd = "城市:" + d["cityInfo"]["city"] + " \n温度:" + d["data"]["wendu"]
print(dd)
```
```python
import urllib.request
# 专门用来做爬虫的工具包
# request请求访问的功能,后面括号里放上网址
访问页面 = urllib.request.Request("https://docs.python.org/zh-cn/3/library/turtle.html?highlight=turtle#turtle.xcor")
# url 网址 open打开
接收响应 =urllib.request.urlopen(访问页面)
# de 负面意义 code代码,,编码 ----》 decode解码
网页源代码 = 接收响应.read().decode()
print(网页源代码)
boren -爬虫
猜你喜欢
转载自blog.csdn.net/houlaos/article/details/104013899
今日推荐
周排行