关于python requests接口测试报错
关于python requests接口测试报错(有可能信息头不正确导致)python requests 登陆博客园接口测试,通过抓包,将信息头导入,执行结果报错
<p>import requests
url ="<a href="https://passport.conblog.com/user/signin">https://passport.conblog.com/user/signin</a>"
headers={"Accept":"application/json, text/javascript, */*; q=0.01",
"Content-Type":"application/json; charset=utf-8",
"VerificationToken":"aqgjozX3uTq24P__x9RC8JlTdUIxN1ukPz_CFuMRkz1oWM0fIJEyHNB_cdHxBalmjRy9zMqdyovTHheNLCFVBlsbIe81:cqhZNbTIymgynUxtXTvbNtbM3uAwYw3HP837vOgN01Gqekcvvnx15ql9rEFL-Mwkhv5MMCraudYCP4nkXPLBmeHE26w1",
"X-Requested-With":"XMLHttpRequest",
"Referer":"<a href="https://passport.cnblogs.com/user/signin">https://passport.cnblogs.com/user/signin</a>",
"Accept-Language":"zh-Hans-CN,zh-Hans;q=0.5",
"Accept-Encoding":"gzip,deflate",
"User-Agent":"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; LCJB; rv:11.0) like Gecko",
"Host":"passport.cnblogs.com",
"Content-Length":"385",
"DNT":"1","Connection":"Keep-Alive","Cache-Control":"no-cache",
"Cookie":"_ga=GA1.2.1522036330.1499499340; UM_distinctid=15d36b9c2f23df-0b505bbf4d903b-4016f56-e1000-15d36b9c2f3370; pgv_pvi=4971374592; _gid=GA1.2.1046363634.1499966253; pgv_si=s2117893120; SERVERID=227b087667da6f8e99a1165002db93f6|1500037070|1500036795; ASP.NET_SessionId=n4ntmjjfgjhqcibijfi34fcc"
}
payload ={"input1":"NjjZiMPGjxu0pBIYDcq/P4mwGkpelAXtKXQCwUrPKFugwgIorYGMl8JtfAETMAy/jX2IEeSpEaDaQxa70PfC3LPWcjaShuf9gfK1uV+W/8qUf730bnN9yP0XZNBRUCFLseuKoaPQn9SoAagMG7q82MyTELzB/i7sMQ41EQBZbZA=",
"input2":"cOCAl+VSg8rWK21THabM7jDML8ZuLAMl6FoidsoCom55veS9UasbW2GJd6YQgPSdhhYgOwLRJ6+JihUGE9eZvTuikdGr43ocsE4FGAkAlcZvYRItq+fvmw4bciRneimGfG3xkpn+Dmo0AuUQcKRZKSLS1KsekfPGDRUdka5Lt1k=",
"remember":"True"}
r =requests.post(url,json=payload,headers=headers,verify=False)
print r.json()</p><p>错误信息
D:\Python27\python.exe D:/20180/InterfaceTest/getTest1.py
Traceback (most recent call last):
File "D:/20180/InterfaceTest/getTest1.py", line 19, in <module>
r =requests.post(url,json=payload,headers=headers,verify=False)
File "D:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "D:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\sessions.py", line 502, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\sessions.py", line 612, in send
r = adapter.send(request, **kwargs)
File "D:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\adapters.py", line 502, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='passport.conblog.com', port=443): Max retries exceeded with url: /user/signin (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 502 Fiddler - Connection Failed',)))</p><p>Process finished with exit code 1</p>
代码重新贴一下 好乱 参考下这个链接https://blog.csdn.net/weixin_43579528/article/details/87804748 https://blog.csdn.net/weixin_43579528/article/details/87804748参考下这个链接 代理有问题 可能是超时了 感觉没连接上啊 设置超时时长
页:
[1]