pycurl

Create missing directories in ftplib storbinary

孤街醉人 提交于 2019-12-21 03:43:43
问题 I was using pycurl to transfer files over ftp in python. I could create the missing directories automatically on my remote server using: c.setopt(pycurl.FTP_CREATE_MISSING_DIRS, 1) for some reasons, I have to switch to ftplib. But I don't know how to to the same here. Is there any option to add to storbinary function to do that? or I have to create the directories manually? 回答1: FTP_CREATE_MISSING_DIRS is a curl operation (added here). I'd hazard a guess that you have to do it manually with

SSL error installing pycurl after SSL is set

吃可爱长大的小学妹 提交于 2019-12-21 03:32:52
问题 Just some information to start: I'm running Mac OS 10.7.5 I have curl 7.21.4 installed (came with dev tools I believe) I have python 2.7.1 I've been trying to get pycurl installed, but every time I try to run it, I get: ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other) I first installed pycurl using the setup: python setup.py install Which didn't work (since SSL wasn't configured). I have since uninstalled pycurl ( sudo rm -rf

Custom headers with pycurl

家住魔仙堡 提交于 2019-12-20 17:19:12
问题 Can I send a custom header like "yaddayadda" to the server with the pycurl request? 回答1: I would code something like: pycurl_connect = pycurl.Curl() pycurl_connect.setopt(pycurl.URL, your_url) pycurl_connect.setopt(pycurl.HTTPHEADER, ['header_name1: header_value1', 'header_name2: header_value2']) pycurl_connect.perform() 回答2: you can, with HTTPHEADER. just provide your custom headers as a list, like so: header = ['test: yadayadayada', 'blahblahblah'] curl.setopt(pycurl.HTTPHEADER, header) 回答3

Custom headers with pycurl

依然范特西╮ 提交于 2019-12-20 17:18:52
问题 Can I send a custom header like "yaddayadda" to the server with the pycurl request? 回答1: I would code something like: pycurl_connect = pycurl.Curl() pycurl_connect.setopt(pycurl.URL, your_url) pycurl_connect.setopt(pycurl.HTTPHEADER, ['header_name1: header_value1', 'header_name2: header_value2']) pycurl_connect.perform() 回答2: you can, with HTTPHEADER. just provide your custom headers as a list, like so: header = ['test: yadayadayada', 'blahblahblah'] curl.setopt(pycurl.HTTPHEADER, header) 回答3

Logging in and using cookies in pycurl

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 11:08:30
问题 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

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

坚强是说给别人听的谎言 提交于 2019-12-20 10:37:10
问题 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.

Having trouble installing pycurl on windows

二次信任 提交于 2019-12-19 09:21:41
问题 I'm having trouble getting pycurl installed on my windows computer. At first I tried pip, but ran into the “Please specify --curl-dir=/path/to/built/libcurl” error, and have since tried installing curl before running it again. I downloaded curl from http://curl.haxx.se/download.html and have extracted it into it's own folder. I tried the following: D:\Downloads\pycurl-7.19.5.1\pycurl-7.19.5.1>python setup.py install --curl-dir="D:\Downloads\curl-7.40.0\curl-7.40.0" But received the following

Convert io.BytesIO to io.StringIO to parse HTML page

a 夏天 提交于 2019-12-18 14:13:12
问题 I'm trying to parse a HTML page I retrieved through pyCurl but the pyCurl WRITEFUNCTION is returning the page as BYTES and not string, so I'm unable to Parse it using BeautifulSoup. Is there any way to convert io.BytesIO to io.StringIO? Or Is there any other way to parse the HTML page? I'm using Python 3.3.2. 回答1: A naive approach: # assume bytes_io is a `BytesIO` object byte_str = bytes_io.read() # Convert to a "unicode" object text_obj = byte_str.decode('UTF-8') # Or use the encoding you

Convert curl example to pycurl

眉间皱痕 提交于 2019-12-17 23:18:47
问题 Could someone convert the following PostMark curl example to pycurl? curl -X POST "http://api.postmarkapp.com/email" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "X-Postmark-Server-Token: ed742D75-5a45-49b6-a0a1-5b9ec3dc9e5d" \ -v \ -d "{From: 'sender@example.com', To: 'receiver@example.com', Subject: 'Postmark test', HtmlBody: '<html><body><strong>Hello</strong> dear Postmark user.</body></html>'}" 回答1: You can use something like this. It's a basic

How do I get the IP address from a http request using the requests library?

五迷三道 提交于 2019-12-17 10:42:34
问题 I am making HTTP requests using the requests library in python, but I need the ip address from the server that responded the http request and I'm trying to avoid to make two calls (and possibly having a different ip address from the one that responded the request. Is that possible? Does any python http library allows me to do that? ps: I also need to make HTTPS requests and to use an authenticated proxy. Update 1: Example: import requests proxies = { "http": "http://user:password@10.10.1.10