草庐IT

Requests_Response

全部标签

python - 在 pypi 上注册包时为 "Server response (401): You must login to access this feature"

我正在尝试在pyPI上注册一个包。在创建一个看起来像的.pypirc之后[distutils]#thistellsdistutilswhatpackageindexesyoucanpushtoindex-servers=pypipypitest[pypi]repository:https://pypi.python.org/pypiusername:"amfarrell"password:"Idontpostmypassphrasepublicly"[pypitest]repository:https://testpypi.python.org/pypiusername:"amfarr

Python - requests.exceptions.SSLError - dh key 太小

我正在使用Python和请求抓取一些内部页面。我已经关闭了SSL验证和警告。requests.packages.urllib3.disable_warnings()page=requests.get(url,verify=False)在某些服务器上,我收到无法通过的SSL错误。Traceback(mostrecentcalllast):File"scraper.py",line6,inpage=requests.get(url,verify=False)File"/cygdrive/c/Users/jfeocco/VirtualEnv/scraping/lib/python3.4/si

python - 类型错误 : 'Response' object has no attribute '__getitem__'

我试图从字典中的响应对象中获取一个值,但我一直遇到这个错误,我认为你__getitem__更常用于类中的索引是不是我错了?代码如下:importjsonimportrequestsfromrequests.authimportHTTPBasicAuthurl="http://public.coindaddy.io:4000/api/"headers={'content-type':'application/json'}auth=HTTPBasicAuth('rpc','1234')payload={"method":"get_running_info","params":{},"jso

python - render_to_response 给出 TemplateDoesNotExist

我正在使用获取模板的路径paymenthtml=os.path.join(os.path.dirname(__file__),'template\\payment.html')并在另一个应用程序中调用它paymenthtml被复制到payment_templatereturnrender_to_response(self.payment_template,self.context,RequestContext(self.request))但是我得到错误TemplateDoesNotExistat/test-payment-url/E:\testapp\template\payment.

python - Heroku ---> 安装 pip 远程 : AttributeError: module 'pip._vendor.requests' has no attribute 'Session'

一个Python3.6Django==11应用程序正在部署,并且代码会定期推送到昨天。现在我有错误:remote:AttributeError:module'pip._vendor.requests'hasnoattribute'Session'整个轨迹:Countingobjects:3,done.Deltacompressionusingupto4threads.Compressingobjects:100%(2/2),done.Writingobjects:100%(3/3),273bytes|0bytes/s,done.Total3(delta1),reused0(delta0

python - scrapy response.xpath 在具有默认命名空间的 xml 文档上返回空数组,而 response.re 有效

我是scrapy的新手,我正在玩scrapyshell试图抓取这个网站:www.spiegel.de/sitemap.xml我用scrapyshell"http://www.spiegel.de/sitemap.xml"在我使用的时候一切正常response.body我可以看到整个页面,包括xml标签但是例如这个:response.xpath('//loc')根本行不通。我得到的结果是一个空数组同时response.selector.re('somevalidregexpexpression')会起作用知道可能是什么原因吗?可能与编码有关?该网站不是utf-8我在Win7上使用pyth

python - 请求 response.iter_content() 得到不完整的文件(1024MB 而不是 1.5GB)?

您好,我一直在使用此代码片段从网站下载文件,目前小于1GB的文件都很好。但我注意到一个1.5GB的文件不完整#sisrequestssessionobjectr=s.get(fileUrl,headers=headers,stream=True)start_time=time.time()withopen(local_filename,'wb')asf:count=1block_size=512try:total_size=int(r.headers.get('content-length'))print'filetotalsize:',total_sizeexceptTypeErro

python - 如何使用 Requests 和 JSON 打印变量

我一直在编写一个从在线API提取信息的应用程序,我需要一些帮助。我用的是requests,我现在的代码如下myData=requests.get('theapiwebsitehere.com/thispartisworking')myRealData=myData.json()x=myRealData['data']['playerStatSummaries']['playerStatSummarySet']['maxRating']printx然后我得到这个错误myRealData=myData.json()TypeError:'NoneType'objectisnotcallabl

python - Python/Firefox headless 抓取脚本中的 "Failed to decode response from marionette"消息

美好的一天,我在这里和谷歌上进行了大量搜索,但尚未找到解决此问题的解决方案。场景是:我有一个Python脚本(2.7),它循环访问许多URL(例如,想想亚马逊页面、抓取评论)。每个页面都有相同的HTML布局,只是抓取不同的信息。我将Selenium与headless浏览器一起使用,因为这些页面具有需要执行以获取信息的javascript。我在我的本地机器(OSX10.10)上运行这个脚本。Firefox是最新的v59。Selenium的版本为3.11.0,使用的是geckodriverv0.20。此脚本在本地没有问题,它可以遍历所有URL并毫无问题地抓取页面。现在,当我将脚本放在我的服

python - Flask: 'Response' 对象不可迭代并产生响应异常

在Flask0.10.1中,我似乎无法再从异常中生成响应(0.9也是如此)。这段代码:fromflaskimportFlask,jsonifyfromwerkzeug.exceptionsimportHTTPExceptionimportflask,werkzeugprint'Flaskversion:%s'%flask.__version__print'Werkzeugversion:%s'%werkzeug.__version__app=Flask(__name__)app.config['PROPAGATE_EXCEPTIONS']=TrueclassJSONException(