简体   繁体   English

如何从pycurl获取原始curl请求?

[英]How to get the original curl request from pycurl?

Is there any way if i use,如果我使用,有什么办法吗,

 crl = pycurl.Curl()
 crl.setopt(pycurl.URL, "www.google.com")

i need to print the original curl request for troubleshooting我需要打印原始卷曲请求以进行故障排除

curl www.google.com

There is no feature in pycurl that composes curl commands. pycurl 中没有组成 curl 命令的功能。

Note also that there are many things you can do with pycurl that cannot be represented with curl command (for example, writing to a Python IO object).另请注意,您可以使用 pycurl 执行许多无法用 curl 命令表示的操作(例如,写入 Python IO 对象)。

You could use subprocess to get the output:您可以使用 subprocess 来获取输出:

import subprocess
process = subprocess.Popen(["curl","www.google.com"],shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
print(stdout.decode().strip() , stderr.decode().strip())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM