Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'load' of undefined #17

Closed
CncCbz opened this issue Mar 20, 2021 · 10 comments

Comments

@CncCbz
Copy link

CncCbz commented Mar 20, 2021

image
按照README写的demo无法获取到conf?

@beetcb
Copy link
Owner

beetcb commented Mar 20, 2021

目前版本的 API 有些 Breaking Changes:
我的 repo 里有个现成的更好的例子:

cea/TEST/dcampus.js

Lines 1 to 25 in 730481c

const cea = require('../src/index')
;(async () => {
// Log in and save cookie to cea, using cea.get('cookie') to get them (this function resolve with an users array)
const usersWithTask = await cea.handleCookie()
// Sign in
const logs = await signIn(usersWithTask)
// Log out sign in result
console.table(logs)
})()
async function signIn(usersWithTask) {
const logs = {}
// sign in asynchronizedly with promise all and diff instance of signApp class
await Promise.all(
usersWithTask.map(async i => {
await i.sign.signWithForm()
logs[i.alias || i.id] = i.sign.result
// Fix circular object
delete i.sign
})
)
cea.close()
return logs
}

@CncCbz

@CncCbz
Copy link
Author

CncCbz commented Mar 20, 2021

目前版本的 API 有些 Breaking Changes:
我的 repo 里有个现成的更好的例子:

cea/TEST/dcampus.js

Lines 1 to 25 in 730481c

const cea = require('../src/index')
;(async () => {
// Log in and save cookie to cea, using cea.get('cookie') to get them (this function resolve with an users array)
const usersWithTask = await cea.handleCookie()
// Sign in
const logs = await signIn(usersWithTask)
// Log out sign in result
console.table(logs)
})()
async function signIn(usersWithTask) {
const logs = {}
// sign in asynchronizedly with promise all and diff instance of signApp class
await Promise.all(
usersWithTask.map(async i => {
await i.sign.signWithForm()
logs[i.alias || i.id] = i.sign.result
// Fix circular object
delete i.sign
})
)
cea.close()
return logs
}

@CncCbz

我尝试使用这个demo,但是好像加密密码阶段的key获取不到,是undefined,请问是我哪里没有设置对吗?
image

@beetcb
Copy link
Owner

beetcb commented Mar 20, 2021

具体要看学校登录页面了,不同学校不一样 (~ ̄▽ ̄)~

这是(也就是你 Debug 的代码)是登录的核心代码:

cea/crawler/casLogIn.js

Lines 48 to 51 in a39a9a2

password: new AES(
user.password,
$('#pwdEncryptSalt', form).attr('value')
).encrypt(),

你看看你们学校是什么元素,还有需不需要加密密码 @CncCbz

@beetcb
Copy link
Owner

beetcb commented Mar 20, 2021

@CncCbz 忘说了,也可以贴一下学校名字,我明天看看 🦄

@CncCbz
Copy link
Author

CncCbz commented Mar 20, 2021

@CncCbz 忘说了,也可以贴一下学校名字,我明天看看 🦄

宁波大学o(╥﹏╥)o,我比较菜,谢谢大佬

@beetcb
Copy link
Owner

beetcb commented Mar 20, 2021

@CncCbz 害,不是大佬,其实多花点时间看看应该就可以成功。这是开源项目,随时欢迎交流(贡献)

@beetcb
Copy link
Owner

beetcb commented Mar 21, 2021

@CncCbz 更新到 cea@2.1.4,适配性更强,你使用你的账号测试一下,看看有没有问题

如果登录失败,看看登录提交的表单和下面是否类似:

image

@CncCbz
Copy link
Author

CncCbz commented Mar 21, 2021

@beetcb 表单没有问题(图1),但是返回的执行recook判断时,返回的是false(图二)我用手动post了一下,response headers也是没有set-cookies的
image
image

@beetcb
Copy link
Owner

beetcb commented Mar 21, 2021

如果登录失败,看看登录提交的表单和下面是否类似:

这里是说去浏览器手动成功登录一下看看表单是什么样子的,再和本地对比下 @CncCbz

愿意的话也可以把账号发我邮箱,帮你看看 i@beetcb.com

@beetcb
Copy link
Owner

beetcb commented Mar 24, 2021

@CncCbz 最新版本已修复,先 close 掉了!

@beetcb beetcb closed this as completed Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants