py12306
py12306 copied to clipboard
登陆失败
正在校验验证码... 校验验证码成功 正在登录... 登陆失败啦!重新登陆... { "validateMessagesShowId": "_validatorMessage", "status": false, "httpstatus": 200, "messages": [ "网络繁忙,请您重试。如正在使用第三方购票软件或插件,请卸载后重试。" ], "validateMessages": {} } 正在等待验证码... 请输入4位图片验证码(回车刷新验证码):
应该是12306系统升级了,需要改http头
@iclear 我这请求 https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn 的时候返回的result总是0 请问是不是也是这个原因?
@ReZELChan @iclear 啊,试出来了,http头里多了个
'Origin': 'https://kyfw.12306.cn'
@ReZELChan 懂了,你比我走的远 你这应该是 https://kyfw.12306.cn/otn/login/loginAysnSuggest 的时候 randCode_validate 没处理 这个随机值得算的。。
@jminht 验证码貌似没问题的,在当前文件夹下手工打开图片,然后把验证码填到命令行就可以了。 但是后面还是会返回登录失败。
是因为系统登录的时候,post的body里增加了个key value对,这个key value对是需要解析js脚本获取到才可以的
@p1o2p3u1 正解
@p1o2p3u1 @jminht 有解决方案吗
http 头添加 'Origin' 了 全部必须数据提交后还是返回, 网络繁忙,请您重试。如正在使用第三方购票软件或插件,请卸载后重试。
可以试试这个 https://github.com/p1o2p3u1/py12306/compare/huzhifeng:master...master
@p1o2p3u1 你说的对,就应该用pyV8来解析js,直接调用函数得到key和value
搜索ODUxODA5来到了这里,呵呵呵。
I am thinking about re-implementing the functions in Python: encode32, bin216, Base32
This way we don't have to rely on PyV8, will update if I succeed.
I've implemented the functions in python, so no need to use PyV8 anymore, I'm still having issues logging in though. Unit tests included.