试图发表简单的帖子并获取请求,仍然会出现错误
我试图刮擦网页,但无法访问使用该服务动态加载的端点。我检查了网络选项卡并找到了服务,并试图模拟请求,获取错误 在这里输入映像说明
尝试使用具有相同有效载荷的Queryparameters提出get请求,从而获得httpp http 400错误。请有人帮助!
我附上了一张图片,请检查一下并提供帮助!
代码如下
import requests
payload = {'doctorId':'739559',
'regdNovalue':'3608'}
headers = {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '42',
'Content-Type': 'application/json',
'Cookie': 'JSESSIONID=-jU0dgec3PJUA-
bjaUtO3aPvIUnX2Zz4I31sRlrX.web3;
PHPSESSID=0lmo0b9av7vob0m66c1ugtm840',
'Host': 'www.nmc.org.in',
'Origin': 'https://www.nmc.org.in',
'Referer': 'https://www.nmc.org.in/information-desk/indian-
medical-register/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="101",
"Google Chrome";v="101"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/101.0.4951.67 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'}
url = "https://www.nmc.org.in/MCIRest/open/getDataFromService?service=getDoctorDetailsByIdImr"
res1 = requests.get(url, params = payload,headers=headers)
res2 = requests.post(url, data = payload,headers=headers)
TIA
Im trying to scrape a webpage, but unable to access the endpoint which is dynamically loaded using the service. I checked the network tab and found the service and tried to mock a request, getting error
enter image description here
tried to make a get request using the queryparameters with the same payload, getting http 400 error. please someone help!
I have attached a picture, please check it out and help!
The code is as below
import requests
payload = {'doctorId':'739559',
'regdNovalue':'3608'}
headers = {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '42',
'Content-Type': 'application/json',
'Cookie': 'JSESSIONID=-jU0dgec3PJUA-
bjaUtO3aPvIUnX2Zz4I31sRlrX.web3;
PHPSESSID=0lmo0b9av7vob0m66c1ugtm840',
'Host': 'www.nmc.org.in',
'Origin': 'https://www.nmc.org.in',
'Referer': 'https://www.nmc.org.in/information-desk/indian-
medical-register/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="101",
"Google Chrome";v="101"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/101.0.4951.67 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'}
url = "https://www.nmc.org.in/MCIRest/open/getDataFromService?service=getDoctorDetailsByIdImr"
res1 = requests.get(url, params = payload,headers=headers)
res2 = requests.post(url, data = payload,headers=headers)
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要从服务器获取数据,请使用
json =
参数:打印:
To get data from the server, use
json=
parameter:Prints: