cURL 转 Python Requests
粘贴浏览器中复制的 cURL 命令,即时生成可运行的 Python 请求代码。
01cURL 命令
02Python Requests
import requests
url = 'https://httpbin.org/anything?page=1'
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Client': 'spider-tools',
}
json_data = {
'keyword': 'Python 爬虫',
'limit': 10,
}
response = requests.post(
url,
headers=headers,
json=json_data,
)
print(response.status_code)
print(response.text)支持 Header、Cookie、JSON、表单、Basic Auth、代理等常用参数