python包管理工具
pip
若发现报错,则可以通过
-i
命令指定软件源
requests库安装
通过
pip
,如上
或通过
pycharm


搜索
requests
,并安装即可

下载成功的证明

requests库使用
模拟
http
重要参数如下


如何模拟发包

支持模拟各种
http method


代理获取数据包
proxy={"http":"127.0.0.1:8080","https":"127.0.0.1:8080"}
r=requests.get(url="http://www.baidu.com",proxies=proxy)
修改请求头
header={"User-Agent":"666"}
r=requests.get(url="http://www.baidu.com",proxies=proxy,headers=header)
模拟
get
请求传参和
post
请求传参
para={'a':'b'}
data={'a':'b'}
r=requests.post(url="http://www.baidu.com",params=para,data=data,proxies=proxy,h
eaders=header)
params为get请求传参
data为post请求传参
模拟
cookie
传参
cookie={'a':'213'}
r=requests.post(url="http://www.baidu.com",cookies=cookie,params=para,data=data,
proxies=proxy,headers=header)
解决
https
报错问题
verify=False #该字段的作用为忽略证书校验