'''HTTP请求示例和字节流转换方法示例.py''' import requests
url = "http://www.baidu.com/"
headers = {"User-Agent":"Mozilla/5.0"}
发送HTTP请求并获取响应
response = requests.get(url,headers=headers)
response.encoding = "utf-8"
获取字符串类型的响应内容
print(type(response.text))
获取字节流类型的响应内容
print(type(response.content))
返回服务器响应码
print(response.status_code)
返回数据的URL
print(response.url)
暂无评论