我写了一个爬虫,
这个网页输入相关信息以后,会根据输入弹出新窗口。新窗口的网址包括输入信息和sessionId,比如:http://cx.mem.gov.cn/cms/html/certQuery/certQuery.do?method=getCertQueryResult&ref=ch&certtype_code=720&certnum=%D5%C5%C8%FD&stu_name=123456199909099999&passcode=2614&sessionId=F9D21F025EDF8551C6CD2C2B6A11F3F9
怀疑post的时候,没上传姓名等信息,是只给系统发个时间戳的请求?
其中sessionId由query string parameters的一个method=getServerTime参数返回,如{time: "F9D21F025EDF8551C6CD2C2B6A11F3F9"}
我使用requests的post上传数据后,始终不能返回这个time参数。
status_code是200,但没有结果。
请指教,问题出在哪儿了?
import requests
import json
BasePath="http://cx.mem.gov.cn/cms/html/certQuery/certQuery.do?method=getServerTime"
url='http://cx.mem.gov.cn//cms/html/certQuery/certQuery.do?method=getServerTime'
headers={
'Cookie': 'JSESSIONID=FCAB031F44065EDD76A76F74F2A2DA5A; acw_tc=3ccdc14216776771338426158e28f15d171fa099438e81826267875f2cf69b',
'Host': 'cx.mem.gov.cn',
'Origin': 'http://cx.mem.gov.cn',
'Referer': 'http://cx.mem.gov.cn/cms/html/certQuery/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57',
}
para={'method':'getServerTime'}
r=requests.post(url=url,headers=headers,params=para)
print(r.status_code)
print(r.text)
你可以用postman等请求工具试试,可能是被识别爬虫然后反爬虫了