Skip to content
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

挂号失败,post 的 response 是一个 html #27

Closed
coeusite opened this issue Aug 7, 2017 · 2 comments
Closed

挂号失败,post 的 response 是一个 html #27

coeusite opened this issue Aug 7, 2017 · 2 comments
Labels

Comments

@coeusite
Copy link

coeusite commented Aug 7, 2017

遇到一个BUG,挂号时的 response 不是 json 而是一个 html
bjguahao.py > get_it() > response = self.browser.post(self.confirm_url , data=preload)

尝试测试了一下,结果弄得我自己一头雾水。

在 Chrome 上手动挂号,挂号时同样是

dutySourceId:45004502
hospitalId:122
departmentId:200001019
doctorId:200287869
patientId:**********
hospitalCardId:
medicareCardId:
reimbursementType:-1
smsVerifyCode:763466
childrenBirthday:
isAjax:true
  • 返回值如下:
code:200
data:******
hasError:false
msg:"OK"

用脚本挂同一个号,post 的数据基本一致,除了SMS码和reimbursementType,但返回值的response.text却是个HTML,且挂号不成功。
response.text写入文件后发现是选择时间的那个挂号页。

@coeusite
Copy link
Author

coeusite commented Aug 7, 2017

Chrome 中发送 POST 请求时的 Headers:

POST /order/confirm.htm HTTP/1.1
Host: www.bjguahao.gov.cn
Connection: keep-alive
Content-Length: 202
Origin: http://www.bjguahao.gov.cn
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
DNT: 1
Referer: http://www.bjguahao.gov.cn/order/confirm/122-200001019-200287869-45004502.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2
Cookie: ******

脚本 POST 时的 Headers:

{
'Referer': u'http://www.bjguahao.gov.cn/order/confirm/122-200001019-200287869-45004502.htm', 
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
}

我修改了一下,这个Headers也不好用(response.request.headers)

{
'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2', 
'Accept-Encoding': 'gzip, deflate', 
'Accept': 'application/json, text/javascript, */*; q=0.01', 
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36', 
'DNT': '1', 
'Host': 'www.bjguahao.gov.cn', 
'Origin': 'http://www.bjguahao.gov.cn', 
'Referer': u'http://www.bjguahao.gov.cn/order/confirm/122-200001019-200287869-45004502.htm', 
'Cookie': 'SESSION_COOKIE=***; JSESSIONID=***', 
'X-Requested-With': 'XMLHttpRequest'
}

@coeusite coeusite changed the title 挂号失败 挂号失败,post 的 response 是一个 html Aug 7, 2017
@iBreaker iBreaker added the bug label Aug 7, 2017
@iBreaker
Copy link
Owner

iBreaker commented Aug 9, 2017

问题解决

@iBreaker iBreaker closed this as completed Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants