医某保服务平台
说明
代码实现
spider.py
import requests, execjs, time
cookies = {
'amap_local': '510100',
'yb_header_active': '-1',
}
headers = {
'Accept': 'application/json',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Type': 'application/json',
'Origin': 'https://fuwu.nhsa.gov.cn',
'Pragma': 'no-cache',
'Referer': 'https://fuwu.nhsa.gov.cn/nationalHallSt/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
'X-Tingyun': 'c=B|4Nl_NnGbjwY;x=7b3059fe70ca40d3',
'channel': 'web',
'contentType': 'application/x-www-form-urlencoded',
'sec-ch-ua': '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'x-tif-nonce': 'D8SRNPWZ',
'x-tif-paasid': 'undefined',
'x-tif-signature': 'f0fd5eb8dcdbf6d35834a7f9bba31d4ab97c729510bd5541cedc266eeacc2f57',
'x-tif-timestamp': '1740112310',
# 'Cookie': 'amap_local=510100; yb_header_active=-1',
}
# 读js
js_compile = execjs.compile(open('./main.js', 'r', encoding='utf-8').read())
for page in range(1, 4):
# 调用js加密请求数据,type: str
cipher_req = js_compile.call("encryptReq", page)
response = requests.post(
'https://fuwu.nhsa.gov.cn/ebus/fuwu/api/nthl/api/CommQuery/queryRtalPhacBInfo',
cookies=cookies,
headers=headers,
data=cipher_req,
)
# 调用JS解密
plain_data = js_compile.call("decryptRes", response.json())
items_list = plain_data['list']
# print(items_list)
print(f'Page{page}:')
# 遍历信息
for item in items_list:
print(f"{item['medinsName']} 电话:{item.get('tel')} 地址:{item.get('addr')}")
time.sleep(2)main.js
loader.js
Last updated