立即学习:https://edu.csdn.net/course/play/24756/280666?utm_source=blogtoedu
1.get请求:
import requests
headers={'User-Agent':' '}
kw={'wd':'中国'}
#params接受字典或字符串的查询参数,字典类型自动转换为url编码,不需要urlencode()
resp=requests.get('url',headers=headers,params=kw)
print(resp)
#查询响应内容:
如:print(resp.text)#返回Unicode格式的数据,即文本格式
or print(resp.content)#返回字节流数据,如果乱码,用decode解码
or print(resp.url)