Archana suregaonkar
Archana suregaonkar

Reputation: 23

python pycurl equivalent of curl -b get command

How to convert a curl get command to equivalent pycurl command, specifically for the command :

curl -b "email=EMAIL; password=PASS" https://storkcloud.org/api/stork/ls?uri=ftp://ftp.mozilla.org/

Upvotes: 2

Views: 895

Answers (2)

Eric
Eric

Reputation: 97591

Use the requests module:

import requests
r = requests.get(
    'https://storkcloud.org/api/stork/ls?uri=ftp://ftp.mozilla.org/',
    cookies=dict(email="EMAIL", password="PASS")
)
print r.text

Upvotes: 1

letsBeePolite
letsBeePolite

Reputation: 2251

Not the pycurl equivalent but does the work, what you intend to do:
Try this(Tried and tested out):

import requests
import os
import json

if os.path.exists("input.json"):
        os.remove("input.json")

stmt = """curl -b "email=XXX; password=YYY\" https://storkcloud.org/api/stork/ls?uri=ftp://ftp.mozilla.org >> input.json"

returnValue = os.system(stmt)

with open("input.json") as json_file:
        json_data = json.load(json_file)

print json_data

Hope this answers your query.

Upvotes: 0

Related Questions