如何在 python 中获得此请求的响应?

How to get response with this request in python?

您好,我有一个请求

GET https://dropezy.goadda.in/master/v1/id/products/search?q=buah&storeId=619e02f0f580166d48277fc0&sortBy=relevance HTTP/2.0
accept: application/json
enro-api-key: rhcvwcdd-7aza-zvv7qskyu-4b8jm8kwppkf
cache-control: max-age=31536000
store-id: 619e02f0f580166d48277fc0
user-agent: Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86 Build/RSR1.201013.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36
content-type: application/json; charset=utf-8
origin: https://www.dropezy.com
x-requested-with: com.enroco.dropezy
sec-fetch-site: cross-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://www.dropezy.com/id/search/
accept-encoding: gzip, deflate
accept-language: en-US,en;q=0.9
content-length: 0

当我尝试在 python 中使用请求时 returns 找不到消息 这是我当前的代码

url = 'https://dropezy.goadda.in/master/v1/id/products/search?q=buah&storeId=619e02f0f580166d48277fc0&sortBy=relevance HTTP/2.0'
accept='application/json'

jsonData = requests.post(url, accept).json() 

有人可以帮忙吗?如何将用户代理、enro-api-key 等其他组件插入到请求中?

这两个请求不一样。第一个是 GET 请求,第二个是 POST.

使用 requests.get 发出 GET 请求。

如果您需要在请求中提供 headers,是的,您可以这样做:https://docs.python-requests.org/en/latest/user/quickstart/#custom-headers.

总的来说,Requests 的文档都很好:https://docs.python-requests.org/en/latest/