[英]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
但是,当您导航到由response.url生成的url时,我试图返回收到的完整html。
查看源代码: http : //www.americhoice.com/find_doctor/Ver2/results_doc.jsp?specialty=ORSU&docproducts=HOBD%2CHLOP&planNameDropDoc=HOBD%2CHLOP&plan=uhcwa&zip=98122&zipradius=10&findButton= FIND+DOCTORTHOPERY& SpecialtyName=
问题似乎是请求没有正确发送GET查询参数
我尝试过的事情(未成功):1)请求完整的URL(已编码),而不是使用params字典2)使用urllib3库而不是Requests库
首先,您提供的查看源网站返回404错误。
第二,打印response.url
会得到什么? 它应该返回完整的URL,包括串联的params
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.