草庐IT

Requests

全部标签

Python Requests requests.exceptions.SSLError : [Errno 8] _ssl. c:504: EOF 发生违反协议(protocol)

我在Ubuntu12.10上使用OpenSSL1.0.1c、python2.7.3、Requests1.0.3和1.0.4(都尝试过),以及尝试使用以下代码在url变量中连接到网站时。defSendInitialRequest(xmlmessage,redirecturl):url='https://centineltest.cardinalcommerce.com/maps/txns.asp'payload='cmpi_msg='+ET.tostring(xmlmessage)headers={'Content-Type':'application/x-www-form-urlenc

Python Requests requests.exceptions.SSLError : [Errno 8] _ssl. c:504: EOF 发生违反协议(protocol)

我在Ubuntu12.10上使用OpenSSL1.0.1c、python2.7.3、Requests1.0.3和1.0.4(都尝试过),以及尝试使用以下代码在url变量中连接到网站时。defSendInitialRequest(xmlmessage,redirecturl):url='https://centineltest.cardinalcommerce.com/maps/txns.asp'payload='cmpi_msg='+ET.tostring(xmlmessage)headers={'Content-Type':'application/x-www-form-urlenc

python - Python 中的简单 URL GET/POST 函数

我似乎无法谷歌它,但我想要一个这样做的函数:接受3个参数(或更多,随便):网址参数字典POST或GET将结果和响应代码返回给我。有这样的片段吗? 最佳答案 请求https://github.com/kennethreitz/requests/以下是几种常用的使用方法:importrequestsurl='https://...'payload={'key1':'value1','key2':'value2'}#GETr=requests.get(url)#GETwithparamsinURLr=requests.get(url,pa

python - Python 中的简单 URL GET/POST 函数

我似乎无法谷歌它,但我想要一个这样做的函数:接受3个参数(或更多,随便):网址参数字典POST或GET将结果和响应代码返回给我。有这样的片段吗? 最佳答案 请求https://github.com/kennethreitz/requests/以下是几种常用的使用方法:importrequestsurl='https://...'payload={'key1':'value1','key2':'value2'}#GETr=requests.get(url)#GETwithparamsinURLr=requests.get(url,pa

python - 有没有一种简单的方法可以在 python 中请求 URL 而不是遵循重定向?

查看urllib2的源代码,看起来最简单的方法是将HTTPRedirectHandler子类化,然后使用build_opener覆盖默认的HTTPRedirectHandler,但这似乎需要做很多(相对复杂的)工作来做看起来像应该很简单。 最佳答案 这里是Requests方式:importrequestsr=requests.get('http://github.com',allow_redirects=False)print(r.status_code,r.headers['Location'])

python - 有没有一种简单的方法可以在 python 中请求 URL 而不是遵循重定向?

查看urllib2的源代码,看起来最简单的方法是将HTTPRedirectHandler子类化,然后使用build_opener覆盖默认的HTTPRedirectHandler,但这似乎需要做很多(相对复杂的)工作来做看起来像应该很简单。 最佳答案 这里是Requests方式:importrequestsr=requests.get('http://github.com',allow_redirects=False)print(r.status_code,r.headers['Location'])

python - 为什么 requests.get() 不返回? requests.get() 使用的默认超时是多少?

在我的脚本中,requests.get永远不会返回:importrequestsprint("requesting..")#Thiscallneverreturns!r=requests.get("http://www.some-site.example",proxies={'http':'222.255.169.74:8080'},)print(r.ok)可能的原因是什么?有什么补救措施吗?get使用的默认超时时间是多少? 最佳答案 Whatisthedefaulttimeoutthatgetuses?默认超时是None,这意味着

python - 为什么 requests.get() 不返回? requests.get() 使用的默认超时是多少?

在我的脚本中,requests.get永远不会返回:importrequestsprint("requesting..")#Thiscallneverreturns!r=requests.get("http://www.some-site.example",proxies={'http':'222.255.169.74:8080'},)print(r.ok)可能的原因是什么?有什么补救措施吗?get使用的默认超时时间是多少? 最佳答案 Whatisthedefaulttimeoutthatgetuses?默认超时是None,这意味着

Python Requests 库重定向新的 url

我一直在查看PythonRequests文档,但我看不到我想要实现的任何功能。在我的脚本中,我正在设置allow_redirects=True。我想知道页面是否被重定向到其他地方,新的URL是什么。例如,如果起始URL是:www.google.com/redirect最终到达网址是www.google.co.uk/redirected我如何获得该网址? 最佳答案 您正在寻找requesthistory.response.history属性是指向最终URL的响应列表,可以在response.url中找到。response=reques

Python Requests 库重定向新的 url

我一直在查看PythonRequests文档,但我看不到我想要实现的任何功能。在我的脚本中,我正在设置allow_redirects=True。我想知道页面是否被重定向到其他地方,新的URL是什么。例如,如果起始URL是:www.google.com/redirect最终到达网址是www.google.co.uk/redirected我如何获得该网址? 最佳答案 您正在寻找requesthistory.response.history属性是指向最终URL的响应列表,可以在response.url中找到。response=reques