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

Cannnot read property 'length' of underfined #30

Open
674345386 opened this issue Jan 15, 2018 · 19 comments
Open

Cannnot read property 'length' of underfined #30

674345386 opened this issue Jan 15, 2018 · 19 comments

Comments

@674345386
Copy link

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. (C:\Users\a7822\Downloads\node_12306-master\main.js:330:15)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

@chulinx
Copy link

chulinx commented Jan 15, 2018

同样的报错 😭

@smalltimoo
Copy link

12306 的接口不接受这种错误的时间,拿不到余票信息,改成正确的时间就可以了,或者联系作者加个提示

@674345386
Copy link
Author

@smalltimoo
那正确的时间格式是什么样的啊啊啊

@smalltimoo
Copy link

不是,你输入的是‘2017-02-11’,而事实上现在是买不到2017年的票了的,你要输入能买到票的日期

@674345386
Copy link
Author

@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. (C:\Users\a7822\Downloads\node_12306-master\main.js:330:15)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

@ing0
Copy link

ing0 commented Jan 15, 2018

一样的错误

@smalltimoo
Copy link

其他的都输入对了吗,这个错误说明返回的result里不是个数组

@674345386
Copy link
Author

@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]"
}

@smalltimoo
Copy link

生成的leftTicketUrl不对

@smalltimoo
Copy link

这几天12306请求头改了等作者更新吧,leftTicketUrl后面加了个Z字符

@hongrunhui
Copy link
Owner

你的leftTicketUrl是啥

@hongrunhui
Copy link
Owner

leftTicketUrl现在是爬12306的另一个网页获取到的

@RoyaNsss
Copy link

我也不行 看到leftTicketUrl好像是"https://kyfw.12306.cn/otn/leftTicket/init"

@smalltimoo
Copy link

我用12306查询发现是'leftTicket/queryZ',你代码里面是'leftTicket/query'

@RoyaNsss
Copy link

改成leftTicket/queryZ可以用了 @smalltimoo 谢谢

@hongrunhui
Copy link
Owner

我会在命令行输出那个地址的,你看看是什么

@smalltimoo
Copy link

就是那个值啊

@674345386
Copy link
Author

我才发现。。对于动车,是用不了的,,= =
测试了一下,12306有的票,用工具查询出来是无,是不是没有动车票的功能?
@lhlybly @smalltimoo

@hongrunhui
Copy link
Owner

动车可以加

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants