1. 首页
  2. 编程语言
  3. Python
  4. 使用requests模块发送网络请求示例.py

使用requests模块发送网络请求示例.py

上传者: 2023-06-28 20:12:31上传 PY文件 519B 热度 15次

'''使用requests模块发送网络请求示例.py''' import requests url = "http://www.baidu.com/" headers = {"User-Agent":"Mozilla/5.0"} #发送网络请求并得到响应response = requests.get(url,headers=headers) response.encoding = "utf-8" #获取响应文本内容print(type(response.text)) #获取响应字节流print(type(response.content)) #获取服务器响应码print(response.status_code) #获取请求的URL print(respone.url) #print(respone.encoding) #默认返回编码格式:ISO-8859-1

下载地址
用户评论