使用python请求库

时间:2017-03-23 10:19:44

标签: python django python-requests

我正在尝试使用python请求库发送https请求 我的代码是

full_url = ''.join(['https://', get_current_site(request).domain, '/am/reply'])
data = {'agent_type':'trigger','input':platform,'user':request.user.id}
print  "hi" ### this is printing
a = requests.get(full_url,params=data,verify=False) ##the execution is stucked here even error are not appearing 
print "hello" ## this code is not printed

问题是在请求整个代码被卡住之后没有执行。 我尝试使用python shell验证我的代码,它运行完美。 有什么方法可以调试我的实时请求响应或者有人建议我解决方案

当有http但在切换到https整个代码停止工作后,整个代码工作正常。我甚至试图放置证书文件但也没有成功

1 个答案:

答案 0 :(得分:0)

这很正常。有些网站只接受http和一些https,其中一些都接受。 http端口为80,https端口为端口443.例如,如果网站使用https,则表示安全http。所以他们实际上需要在标题等中提供额外信息。
检查请求api为http
http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

相关问题