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

Commit

Permalink
fix: synchronize branches
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 14, 2021
1 parent 7db6a68 commit 55c4bde
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions campusphere/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ exports.signApp = class signApp extends (
const genNum = Math.floor(Math.random() * posGenFromCitys.length)
this.addr = posGenFromCitys[genNum][2]
return this.locale({
longitude: posGenFromCitys[genNum][0],
latitude: posGenFromCitys[genNum][1],
longitude: posGenFromCitys[genNum][0] + '',
latitude: posGenFromCitys[genNum][1] + '',
})
}

Expand Down
12 changes: 8 additions & 4 deletions crawler/casLogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module.exports = async (school, user) => {

// deal with anti crawlers
headers.Referer = school.login
headers.Origin = school.origin
headers.Host = school.origin.replace(/http(s?)\:\/\//, '')
headers.Host = new URL(school.casOrigin).host
headers.Origin = `https://${headers.Host}`

// get base session -> cookie
res = await fetch(school.login, { headers })
Expand Down Expand Up @@ -87,7 +87,11 @@ module.exports = async (school, user) => {
}

reCook(res, 1, cookie)

// set redirect headers
delete headers['content-type']
delete headers.Host
headers.Referer = headers.Origin

// get campus cookie
try {
Expand All @@ -98,8 +102,8 @@ module.exports = async (school, user) => {
redirect: 'manual',
})
} catch (e) {
log.error(name)
log.object(res)
log.warning(name)
log.error(e)
return null
}

Expand Down
11 changes: 7 additions & 4 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,25 @@ class School {

let res = await prompt(questions)
const isSignAtHome = res.isSignAtHome

res = await fetch(
`https://mobile.campushoy.com/v6/config/guest/tenant/info?ids=${res.ids}`
).catch(err => err)

res = await JSON.parse(await res.text())

const origin = new URL(res.data[0].ampUrl).origin
const casOrigin = res.data[0].idsUrl

school = {
casOrigin,
origin,
isSignAtHome,
login: `${res.data[0].idsUrl}/login?service=${encodeURIComponent(
login: `${casOrigin}/login?service=${encodeURIComponent(
origin
)}/portal/login`,
campusphere: `${origin}/portal/login`,
checkCaptcha: `${res.data[0].idsUrl}/checkNeedCaptcha.htl`,
getCaptcha: `${res.data[0].idsUrl}/getCaptcha.htl`,
checkCaptcha: `${casOrigin}/checkNeedCaptcha.htl`,
getCaptcha: `${casOrigin}/getCaptcha.htl`,
}

const schoolName = res.data[0].name
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"license": "ISC",
"dependencies": {
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.5",
"conf": "^9.0.2",
"inquirer": "^7.3.3",
"js-yaml": "^4.0.0",
"node-fetch": "^2.6.1",
"tesseract.js": "^2.1.4",
"uuid": "^8.3.2",
"cheerio": "^1.0.0-rc.5",
"node-fetch": "^2.6.1"
"uuid": "^8.3.2"
}
}

0 comments on commit 55c4bde

Please sign in to comment.