本帖最后由 qmqsyz 于 2024-7-30 11:39 编辑 这篇文章介绍了新的查询zhwhrq方法:
https://www.flyert.com.cn/t-4644045-1-1.html但是需要抓包,这个难度很大,于是写了个python脚本查看申请进度。
每次查询需要间隔半小时以上,不然会提示“卡号和证件号不可全部为空”
使用方法:安装python环境(不会的百度),将以下代码复制保存为zhwhrq.py,然后运行python zhwhrq.py
import requests
import json
import ssl
from requests.adapters import HTTPAdapter
from urllib3.poolmanager import PoolManager
class UnsafeLegacyRenegotiationAdapter(HTTPAdapter):
def init_poolmanager(self, *args, **kwargs):
context = ssl.create_default_context()
try:
context.options |= ssl.OP_LEGACY_SERVER_CONNECT
except AttributeError:
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
kwargs['ssl_context'] = context
return super().init_poolmanager(*args, **kwargs)
def initialize_cookies():
url = "https://wx.abchina.com/instH5/respectStage.html"
session = requests.Session()
session.mount("https://", UnsafeLegacyRenegotiationAdapter())
response = session.get(url)
if response.status_code == 200:
print("初始化接口请求成功")
return response.cookies
else:
print("初始化接口异常,状态码:", response.status_code)
return None
def send_sms_request(id_number, cookies):
url = "https://wx.abchina.com/instServe/enjoystage/stageapply/getPhoneAndSendSms"
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Host": "wx.abchina.com",
"Origin": "https://wx.abchina.com",
"Referer": "https://wx.abchina.com/instH5/respectStage.html",
"X-Requested-With": "com.tencent.mm"
}
body = {
"data": {
"idNumber": id_number,
"idType": "110001"
}
}
print("获取验证码请求数据:", json.dumps(body, ensure_ascii=False))
session = requests.Session()
session.mount("https://", UnsafeLegacyRenegotiationAdapter())
response = session.post(url, headers=headers, cookies=cookies, data=json.dumps(body))
return response
def check_sms_code(verify_code, cookies):
url = "https://wx.abchina.com/instServe/enjoystage/stageapply/checkSms"
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Host": "wx.abchina.com",
"Origin": "https://wx.abchina.com",
"Referer": "https://wx.abchina.com/instH5/respectStage.html",
"X-Requested-With": "com.tencent.mm"
}
body = {
"data": {
"verifyCode": verify_code
}
}
print("验证验证码请求数据:", json.dumps(body, ensure_ascii=False))
session = requests.Session()
session.mount("https://", UnsafeLegacyRenegotiationAdapter())
response = session.post(url, headers=headers, cookies=cookies, data=json.dumps(body))
return response.json()
def main():
cookies = initialize_cookies()
if not cookies:
return
id_number = input("请输入身份证号:")
while True:
response = send_sms_request(id_number, cookies)
response_data = response.json()
print("获取验证码请求结果:resCode:", response_data.get("resCode"), "resMsg:", response_data.get("resMsg"))
if response_data.get("resCode") == "2000":
cookies.update(response.cookies)
else:
print("身份证号验证失败,请重新输入。")
id_number = input("请输入身份证号:")
continue
while True:
verify_code = input("请输入收到的验证码:")
response = check_sms_code(verify_code, cookies)
print("验证验证码请求结果:resCode:", response.get("resCode"), "resMsg:", response.get("resMsg"))
if response.get("resCode") == "2000":
data = response.get("data")
if data:
try:
data_list = json.loads(data)
for item in data_list:
print(item)
except json.JSONDecodeError:
print("data字符串解析失败")
else:
print("data为空")
return
elif "请重新获取" in response.get("resMsg", ""):
print("验证码已失效,请重新获取。")
break # 跳出内层循环,重新发送验证码
else:
print("验证码验证失败,请重新输入。")
if __name__ == "__main__":
main()