curl

Convert curl example to pycurl

Convert curl example to pycurl Question: 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: ‘[email protected]’, To: ‘[email protected]’, Subject: ‘Postmark test’, HtmlBody: ‘<html><body><strong>Hello</strong> dear Postmark user.</body></html>’}" Asked By: Darth || Source Answers: You can use something like this. …

Total answers: 1

SSL backend error when using OpenSSL

SSL backend error when using OpenSSL Question: 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 …

Total answers: 26

Conversion of curl to Python Requests

Conversion of curl to Python Requests Question: I’m trying to convert the following working request in curl to a python request (using Requests). curl –data ‘query={"tags":["test1","test2"]}’ http://www.test.com/match (I’ve used a fake url but the command does work with the real url) The receiving end (ran in Flask) does this: @app.route("/match", methods=[‘POST’]) def tagmatch(): query = …

Total answers: 7

PycURL Attachments and Progress Functions

PycURL Attachments and Progress Functions Question: Working on a small project utilising an API that you send a request to and then it gives you back a response with a zip file attached which you then download. My first pass at automating this download tried to utilise the setopt(curl.WRITEDATA, fp) function but this proceeded to …

Total answers: 1

pip: cert failed, but curl works

pip: cert failed, but curl works Question: We installed the our root cert on the client, and the https connection works for curl. But if we try to use pip, it fails: Could not fetch URL https://installserver:40443/pypi/simple/pep8/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:499: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed> The …

Total answers: 4

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

JSONDecodeError: Expecting value: line 1 column 1 (char 0) Question: I am getting error Expecting value: line 1 column 1 (char 0) when trying to decode JSON. The URL I use for the API call works fine in the browser, but gives this error when done through a curl request. The following is the code …

Total answers: 25

How to read a CSV file from a URL with Python?

How to read a CSV file from a URL with Python? Question: when I do curl to a API call link http://example.com/passkey=wedsmdjsjmdd curl ‘http://example.com/passkey=wedsmdjsjmdd’ I get the employee output data on a csv file format, like: “Steve”,”421″,”0″,”421″,”2″,””,””,””,””,””,””,””,””,”421″,”0″,”421″,”2″ how can parse through this using python. I tried: import csv cr = csv.reader(open(‘http://example.com/passkey=wedsmdjsjmdd’,”rb”)) for row in cr: …

Total answers: 9

Python request with authentication (access_token)

Python request with authentication (access_token) Question: I am trying to use an API query in Python. From the command line I can use curl like so: curl –header "Authorization:access_token myToken" https://website.example/id This gives some JSON output. myToken is a hexadecimal variable that remains constant throughout. I would like to make this call from python so …

Total answers: 8

How can I un-shorten a URL using python?

How can I un-shorten a URL using python? Question: I have seen this thread already – How can I unshorten a URL? My issue with the resolved answer (that is using the unshort.me API) is that I am focusing on unshortening youtube links. Since unshort.me is used readily, this returns almost 90% of the results …

Total answers: 5

CURL alternative in Python

CURL alternative in Python Question: I have a cURL call that I use in PHP: curl -i -H ‘Accept: application/xml’ -u login:key "https://app.streamsend.com/emails" I need a way to do the same thing in Python. Is there an alternative to cURL in Python? I know of urllib but I have no idea how to use it. …

Total answers: 7