Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从pycurl获取原始curl请求?_Python_Python 3.x_Curl_Python Requests_Pycurl - Fatal编程技术网

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

Python 如何从pycurl获取原始curl请求?,python,python-3.x,curl,python-requests,pycurl,Python,Python 3.x,Curl,Python Requests,Pycurl,如果我用 crl = pycurl.Curl() crl.setopt(pycurl.URL, "www.google.com") 我需要打印原始卷曲请求以进行故障排除 curl www.google.com pycurl中没有组成curl命令的功能 还请注意,pycurl有许多不能用curl命令表示的功能(例如,写入Python IO对象)。您可以使用子流程获得输出: import subprocess process = subprocess.Popen([&qu

如果我用

 crl = pycurl.Curl()
 crl.setopt(pycurl.URL, "www.google.com")
我需要打印原始卷曲请求以进行故障排除

curl www.google.com

pycurl中没有组成curl命令的功能


还请注意,pycurl有许多不能用curl命令表示的功能(例如,写入Python IO对象)。

您可以使用子流程获得输出:

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())

pycurl根本不使用命令行工具,它使用libcurl。