-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
就医160改接口了 刷票不能用了,有谁知道怎么改!!!!!! #50
Comments
api接口改了 然后加了user_key请求 |
|
收到 谢谢!!!
***@***.***
发件人: John
发送时间: 2022-07-13 10:17
收件人: lwm98/health160
抄送: eadywen; Author
主题: Re: [lwm98/health160] 就医160改接口了 刷票不能用了,有谁知道怎么改!!!!!! (Issue #50)
def brush_ticket_new(useKey, unit_id, doc_id, dep_id, weeks, days) -> list:
now_date = datetime.date.today().strftime("%Y-%m-%d")
# url = "https://www.91160.com/doctors/ajaxgetclass.html"
url = "https://gate.91160.com/guahao/v1/pc/sch/doctor?user_key={}&docid={}&doc_id={}&unit_id={}&dep_id={}&date={}&days=6".format(useKey, doc_id, doc_id, unit_id, dep_id, now_date)
r = session.get(url, headers=get_headers())
json_obj = r.json()
print(json_obj)
if "dates" not in json_obj:
if "status" in json_obj:
logging.error("Token过期,重新登陆")
time.sleep(30)
login(configs['username'], configs['password'])
return []
else:
raise RuntimeError("刷票异常: {}".format(json_obj))
date_list: dict = json_obj["dates"]
week_arr = []
for week in weeks:
val = convert_week(week)
key = list(date_list.keys())[list(date_list.values()).index(val)]
week_arr.append(key)
if len(week_arr) == 0:
raise RuntimeError("刷票异常: {}".format(json_obj))
doc_sch = json_obj["sch"]["{}_{}".format(dep_id, doc_id)]
result = []
for day in days:
key = "{}_{}_{}".format(dep_id, doc_id, day)
if key in doc_sch:
doc_sch_day = doc_sch[key]
for week in week_arr:
if week in doc_sch_day:
result.append(doc_sch_day[week])
return [element for element in result if element["y_state"] == "1"]
def set_doctor_configs(useKey):
now_date = datetime.date.today().strftime("%Y-%m-%d")
unit_id = configs["unit_id"]
dep_id = configs["dep_id"]
# url = "https://www.91160.com/dep/getschmast/uid-{}/depid-{}/date-{}/p-0.html".format(
# unit_id, dep_id, now_date)
url = "https://gate.91160.com/guahao/v1/pc/sch/dep?unit_id={}&dep_id={}" \
"&date={}&p=0&user_key={}".format(unit_id, dep_id, now_date, useKey)
r = session.get(url, headers=get_headers())
doctors = r.json()["data"]["doc"]
doc_id_arr = []
doc_name = {}
if configs["doc_id"] == "":
print("=====请选择医生=====\n")
for doctor in doctors:
doc_id_arr.append(doctor["doctor_id"])
doc_name[doctor["doctor_id"]] = doctor["doctor_name"]
print("{}. {}".format(doctor["doctor_id"], doctor["doctor_name"]))
print()
while True:
doctor_index = input("请输入医生编号: ")
is_number = True if re.match(r'^\d+$', doctor_index) else False
if is_number and int(doctor_index) in doc_id_arr:
configs["doc_id"] = doctor_index
configs["doctor_name"] = doc_name[int(doctor_index)]
break
else:
print("输入有误,请重新输入!")
else:
print("当前选择医生为:%s(%s)" % (configs["doctor_name"], configs["doc_id"]))
def init_data():
set_user_configs()
set_city_configs()
set_hospital_configs()
useKey = set_department_configs()
set_doctor_configs(useKey)
set_week_configs()
set_days_configs()
return useKey
def set_department_configs():
url = "https://www.91160.com/ajax/getdepbyunit.html"
data = {
"keyValue": configs["unit_id"]
}
r = session.post(url, headers=get_headers(), data=data)
access_hash = session.cookies.get_dict()["access_hash"]
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
为什么我选择不了日期,而且刷票还存在error提示 |
error提示是正常的,因为原作者代码里输出函数全写的是“以error的方式输出”,其实是正常的。我修改的代码可以一直正常进行到成功抢票之前,抢票成功后填写信息时的API应该改过了,会提示“提交后跳转到首页了,抢票不成功”,还要进一步修改 |
@NewComer00 大神帮忙修改一下吧 |
@happyin123 我修复了一下,现在测试了两个医院的普通门诊挂号,是可以挂到号的。 结合以上几位的答案,并且做了些微调。大家也可以试试看,用下面的链接中的代码替换掉main.py的全部内容即可。 具体修改内容:
|
@NewComer00 感谢大佬 |
为什么我无法选择日期,进入到医生序号后就直接开始挂号了 @NewComer00 |
因为作者的源代码默认就是这么写的。你要指定周几或者上下午的话,需要在
|
更新了user_key、医生列表和提交信息的相关代码。
'weeks': ['1','2','3','4','5','6','7'],周一二三四五六日 ['1','2','3','4','5','6','7'], # 如需更改,例: 周一 ['1'] 周一三五 ['1','3','5'] 周二四 ['2','4'] |
|
好的谢谢 @NewComer00 |
@NewComer00 大神,现在好像不行了,能帮忙看看嘛,感谢 |
问题已经复现,有两种解决办法,选择其一进行即可。 方法一:升级fake-useragent包
参考:fake-useragent/fake-useragent#130 (comment) 方法二:复制json文件
参考:https://blog.csdn.net/weixin_41772761/article/details/120194015 |
@LiuPure 距离我写补丁已经过去大半年了,不确定是否还能正常使用,建议你先找个已知一定有号的科室试验一下能否正常预约挂号。 如果一直提示 |
大佬 现在这个是还能用吗 还是需要根据自己地方的去测试修改代码啊 @NewComer00 |
您可以测试一下自己需要预约的医院中,某个一定有号的科室。如果一直提示 如果您有Web编程相关的经验,建议您针对自己需要的医院科室修改代码,一般来说是data内容不全导致的,可以用F12抓包看一下data里需要添加那些新的键值对。 |
就医160改接口了 刷票不能用了,有谁知道怎么改!!!!!!
The text was updated successfully, but these errors were encountered: