Python 请求 API requests.get() 带有参数的调用未按预期工作(响应忽略参数)
Python Requests API requests.get() call with params is not working as intended (response ignores params)
这是我的代码:
import requests
find_doctors_url = 'http://www.americhoice.com/find_doctor/Ver2/results_doc.jsp'
payload ={"specialty":"ORSU","docproducts":"HOBD,HLOP","planNameDropDoc":"HOBD,HLOP","plan":"uhcwa","zip":"98122","zipradius":"10","findButton":"FIND DOCTOR","specialtyName":"ORTHOPAEDIC SURGERY"}
response = requests.get(find_doctors_url,params=payload)
print(response.url)
print(response.content)
当我打印 response.content 时,我收到的是:
<!-- NEAADR0179 -Anil Kumar Vutikuri *** End-->
<!--BEGIN SETTING HEADERS TO NO CACHE-->
<!--END SETTING HEADERS TO NO CACHE-->
<!--SET SESSION VALUES FROM URL PARAMETERS-->
<!--END SET SESSION VALUES FROM URL PARAMETERS-->
当您导航到以下位置时收到的响应是:
查看源代码:http://www.americhoice.com/find_doctor/Ver2/results_doc.jsp
但是,我正在寻求 return 当您导航到 response.url
生成的 url 时收到的完整 html
问题似乎是请求没有正确发送 GET 查询参数
我尝试过的事情(未成功):
1) 请求完整的 URL(encoded) 而不是使用参数字典
2) 使用 urllib3 库而不是 Requests 库
首先,您给returns 404错误的查看源网站。
其次,打印response.url
会得到什么?它应该 return 完整 url 包括 params
串联。
这是我的代码:
import requests
find_doctors_url = 'http://www.americhoice.com/find_doctor/Ver2/results_doc.jsp'
payload ={"specialty":"ORSU","docproducts":"HOBD,HLOP","planNameDropDoc":"HOBD,HLOP","plan":"uhcwa","zip":"98122","zipradius":"10","findButton":"FIND DOCTOR","specialtyName":"ORTHOPAEDIC SURGERY"}
response = requests.get(find_doctors_url,params=payload)
print(response.url)
print(response.content)
当我打印 response.content 时,我收到的是:
<!-- NEAADR0179 -Anil Kumar Vutikuri *** End-->
<!--BEGIN SETTING HEADERS TO NO CACHE-->
<!--END SETTING HEADERS TO NO CACHE-->
<!--SET SESSION VALUES FROM URL PARAMETERS-->
<!--END SET SESSION VALUES FROM URL PARAMETERS-->
当您导航到以下位置时收到的响应是: 查看源代码:http://www.americhoice.com/find_doctor/Ver2/results_doc.jsp
但是,我正在寻求 return 当您导航到 response.url
生成的 url 时收到的完整 html问题似乎是请求没有正确发送 GET 查询参数
我尝试过的事情(未成功): 1) 请求完整的 URL(encoded) 而不是使用参数字典 2) 使用 urllib3 库而不是 Requests 库
首先,您给returns 404错误的查看源网站。
其次,打印response.url
会得到什么?它应该 return 完整 url 包括 params
串联。