python pycurl相当于curl b get命令

2024-10-03 21:36:25 发布

您现在位置:Python中文网/ 问答频道 /正文

如何将curl get命令转换为等效的pycurl命令,特别是针对以下命令:

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

Tags: httpsorg命令apigetemailftppass
2条回答

使用^{}模块:

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

不是pycurl的等价物,而是做你想做的工作:
试试这个(经过反复试验):

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

希望这能回答你的疑问。在

相关问题 更多 >