简体   繁体   English

python请求的等效curl命令是什么?

[英]What is the equivalent curl command of python requests?

I have the following python code. 我有以下python代码。

import requests
response = requests.request("POST"
        , url = "https://services27.ieee.org/fellowsdirectory/getpageresultsdesk.html"
        , data = {
            'pageNum': 3
            }   
        )

print(response.text)

But I can not figure the equivalent curl command. 但是我不知道等效的curl命令。 Does anybody know the equivalent curl command? 有人知道等效的curl命令吗?

curl -X POST -d '{"pageNum": "3"}' https://services27.ieee.org/fellowsdirectory/getpageresultsdesk.html

What you are passing in data is a dictionnary with the form url encoded parameters as key/value, this is not JSON data, check this 您传入的data是字典,其形式为url编码的参数作为键/值,这不是JSON数据,请检查

Your python code will send the following request : 您的python代码将发送以下请求:

POST https://services27.ieee.org/fellowsdirectory/getpageresultsdesk.html
Host: services27.ieee.org
Content-Length: 9
Content-Type: application/x-www-form-urlencoded

pageNum=3

By default set the content type to application/x-www-form-urlencoded , so you can just use: 默认情况下, 将内容类型设置为application/x-www-form-urlencoded ,因此您可以使用:

curl -d "pageNum=3" "https://services27.ieee.org/fellowsdirectory/getpageresultsdesk.html"

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

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