pycurl

Error installing PyCurl

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried installing pycurl via pip. it didn't work and instead it gives me this error. running install running build running build_py running build_ext building 'pycurl' extension gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/ Python.framework/Versions/2.6/include/python2.6 -c src/pycurl.c -o build/temp.macosx-10.6-universal-2.6/src/pycurl.o src/pycurl.c:85:4: warning: #warning "libcurl

How to read the header with pycurl

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I read the response headers returned from a PyCurl request? 回答1: There are several solutions (by default, they are dropped). Here is an example using the option HEADERFUNCTION which lets you indicate a function to handle them. Other solutions are options WRITEHEADER (not compatible with WRITEFUNCTION) or setting HEADER to True so that they are transmitted with the body. #!/usr/bin/python import pycurl import sys class Storage: def __init__(self): self.contents = '' self.line = 0 def store(self, buf): self.line = self.line + 1 self

Making an API call in Python with an API that requires a bearer token

你离开我真会死。 提交于 2019-12-03 02:34:34
问题 Looking for some help with integrating a JSON API call into a Python program. I am looking to integrate the following API into a Python .py program to allow it to be called and the response to be printed. The API guidance states that a bearer token must be generated to allow calls to the API, which I have done successfully. However I am unsure of the syntax to include this token as bearer token authentication in Python API request. I can successfully complete the above request using cURL with

Installing pycurl on mac

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am very new to python and need help installing the pycurl library on my machine. I am running python 2.7 at the moment. A brief tutorial would be much appreciated. 回答1: Use one of the two methods Method 1: sudo easy_install pycurl Method 2: pip install pycurl 回答2: Try specify the ARCHFLAGS env var: ARCHFLAGS="-arch x86_64" pip install pycurl==7.19.5.1 文章来源: Installing pycurl on mac

SSL backend error when using OpenSSL

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was trying to install pycurl in a virtualenv using pip and I got this error ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other) I read some documentation saying that "To fix this, you need to tell setup.py what SSL backend is used" (source) although I am not sure how to do this since I installed pycurl using pip. How can I specify the SSL backend when installing pycurl with pip? Thanks 回答1: After reading their INSTALLATION file, I was able to solve my problem by setting an

how to use pycurl if requested data is sometimes gzipped, sometimes not?

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm doing this to fetch some data: c = pycurl.Curl() c.setopt(pycurl.ENCODING, 'gzip') c.setopt(pycurl.URL, url) c.setopt(pycurl.TIMEOUT, 10) c.setopt(pycurl.FOLLOWLOCATION, True) xml = StringIO() c.setopt(pycurl.WRITEFUNCTION, xml.write ) c.perform() c.close() My urls are typically of this sort: http://host/path/to/resource-foo.xml Usually I get back 302 pointing to: http://archive-host/path/to/resource-foo.xml.gz Given that I have set FOLLOWLOCATION, and ENCODING gzip, everything works great. The problem is, sometimes I have a URL which

Logging in and using cookies in pycurl

99封情书 提交于 2019-12-03 00:22:18
I need to download a file that is on a password protected page. To get to the page manually I first have to authenticate via an ordinary login page. I want to use curl to fetch this page in script. My script first logins. It appears to succeed--it returns a 200 from a PUT to /login. However, the fetch of the desired page fails, with a 500. I am using a "cookie jar": C.setopt(pycurl.COOKIEJAR, 'cookie.txt') In verbose mode, I can see cookies being exchanged when I fetch the file I need. Now my question: Is there more to using a COOKIEJAR? I believe Curl will store the cookies but you need to

Pycurl and io.StringIO - pycurl.error: (23, 'Failed writing body)

Deadly 提交于 2019-12-02 23:35:25
I'm porting ebay sdk to python3 and I've stumbled upon the following issue. I'm using pycurl to send some HTTP requests. Here is how I configure it: self._curl = pycurl.Curl() self._curl.setopt(pycurl.FOLLOWLOCATION, 1) self._curl.setopt(pycurl.URL, str(request_url)) self._curl.setopt(pycurl.SSL_VERIFYPEER, 0) self._response_header = io.StringIO() self._response_body = io.StringIO() self._curl.setopt(pycurl.CONNECTTIMEOUT, self.timeout) self._curl.setopt(pycurl.TIMEOUT, self.timeout) self._curl.setopt(pycurl.HEADERFUNCTION, self._response_header.write) self._curl.setopt(pycurl.WRITEFUNCTION,

windows 下安装pyspider

匿名 (未验证) 提交于 2019-12-02 22:11:45
今天主要介绍一下在Windows下安装pyspider,pyspider是一款用python编写的网络爬虫框架,这个框架最好是在linux下运行,Windows下运行可能会出现兼容性问题,如果实在要在Windows下运行,最好选择32位版本,64位版本可能会出现运行崩溃问题。 https://www.python.org/downloads/windows/ https://bintray.com/pycurl/pycurl/pycurl/view#files 这里注意一点:一般安装python时已经安装了对应的pycurl,如果没有安装,就单独安装一下。(我一开始安装python 3.7,安装后发现没有安装pycurl,然后我看下载链接中没有对应3.7版本的pycurl,所以又卸载重新安装python 3.5,发现自动安装了pycurl) 3、安装好后要配置python环境变量。这里主要写两个路径,一个是python目录,一个是python目录下的scripts目录(这个主要是为了能使用pip命令)。 这里有个技巧,可以不用自己手动添加,在安装python时有个勾选框(add python to path),默认时不勾选的,如果勾选会自动添加环境变量。 http://localhost:5000 ,出现如下界面,说明可以开始使用了。 文章来源: windows

How to read the header with pycurl

删除回忆录丶 提交于 2019-12-02 21:17:16
How do I read the response headers returned from a PyCurl request? There are several solutions (by default, they are dropped). Here is an example using the option HEADERFUNCTION which lets you indicate a function to handle them. Other solutions are options WRITEHEADER (not compatible with WRITEFUNCTION) or setting HEADER to True so that they are transmitted with the body. #!/usr/bin/python import pycurl import sys class Storage: def __init__(self): self.contents = '' self.line = 0 def store(self, buf): self.line = self.line + 1 self.contents = "%s%i: %s" % (self.contents, self.line, buf) def _