node_12306
node_12306 copied to clipboard
Cannnot read property 'length' of underfined
C:\Users\a7822\Downloads\node_12306-master>node main.js ? 输入日期-time(如:2017-01-27): 2017-02-11 ? 输入始发站拼音-from_station(如:shanghai): guangzhou ? 你选哪一个车站? 广州 ? 输入终点站拼音-end_station(如:hefei): pingnanan (没有这个车站哦,请重新输入) ? 输入终点站拼音-end_station(如:hefei): pingnannan ? 你选哪一个车站? 平南南 ? 输入车次-train_num(如:K1209,多个车次用|分开): D3786 ? 输入邮箱-your_mail(如:[email protected]): [email protected] ? 输入密码或者邮箱授权码-mail_pass: [hidden] ? 是否购买学生票?(y/n): No ? 输入收件人邮箱(如果与上面的邮箱一致请直接回车): (node:840072) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated. leftTicket/query C:\Users\a7822\Downloads\node_12306-master\main.js:251 for (var cr = 0; cr < ct.length; cr++) { ^
TypeError: Cannot read property 'length' of undefined
at b4 (C:\Users\a7822\Downloads\node_12306-master\main.js:251:28)
at IncomingMessage.
同样的报错 😭
12306 的接口不接受这种错误的时间,拿不到余票信息,改成正确的时间就可以了,或者联系作者加个提示
@smalltimoo 那正确的时间格式是什么样的啊啊啊
不是,你输入的是‘2017-02-11’,而事实上现在是买不到2017年的票了的,你要输入能买到票的日期
@smalltimoo ...我还活在2017.。 不过我改成 2018-02-11 还是不行 报一样的错误
C:\Users\a7822\Downloads\node_12306-master\main.js:251 for (var cr = 0; cr < ct.length; cr++) { ^
TypeError: Cannot read property 'length' of undefined
at b4 (C:\Users\a7822\Downloads\node_12306-master\main.js:251:28)
at IncomingMessage.
一样的错误
其他的都输入对了吗,这个错误说明返回的result里不是个数组
@smalltimoo json 是这样。应该没错把 = = { "time": "2018-02-11", "from_station": { "name": "广州", "code": "GZQ", "pinyin": "guangzhou", "suoxie": "gz", "other": "29@gzx" }, "from_station_": "广州", "end_station": { "name": "平南南", "code": "PAZ", "pinyin": "pingnannan", "suoxie": "pnn", "other": "2465@psb" }, "end_station_": "平南南", "train_num": [ "D3714", "D3722" ], "your_mail": "[email protected]", "mail_pass": "****(已隐藏)", "ticket_type": "ADULT", "receive_mail": "[email protected]" }
生成的leftTicketUrl不对
这几天12306请求头改了等作者更新吧,leftTicketUrl后面加了个Z字符
你的leftTicketUrl是啥
leftTicketUrl现在是爬12306的另一个网页获取到的
我也不行 看到leftTicketUrl好像是"https://kyfw.12306.cn/otn/leftTicket/init"
我用12306查询发现是'leftTicket/queryZ',你代码里面是'leftTicket/query'
改成leftTicket/queryZ可以用了 @smalltimoo 谢谢
我会在命令行输出那个地址的,你看看是什么
就是那个值啊
我才发现。。对于动车,是用不了的,,= = 测试了一下,12306有的票,用工具查询出来是无,是不是没有动车票的功能? @lhlybly @smalltimoo
动车可以加