Skip to content

Instantly share code, notes, and snippets.

@zxc0328
Created June 23, 2017 06:39
Show Gist options
  • Select an option

  • Save zxc0328/9cc15b333586ad9b55d93846d5beb611 to your computer and use it in GitHub Desktop.

Select an option

Save zxc0328/9cc15b333586ad9b55d93846d5beb611 to your computer and use it in GitHub Desktop.
getCCNUPortal.js
var request = require('request')
request({
// will be ignored
method: 'POST',
uri: 'http://portal.ccnu.edu.cn/loginAction.do',
followRedirect: false,
headers: {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
},
form: {
"userName": "sid",
"userPass": "pass"
}
}, function(err, httpResponse, body) {
let cookie = httpResponse.headers['set-cookie'][0].split(";")[0] + ";" + httpResponse.headers['set-cookie'][1].split(";")[0]
console.log(cookie)
request({
// will be ignored
method: 'GET',
uri: 'http://portal.ccnu.edu.cn/roamingAction.do?appId=XK',
followRedirect: false,
headers: {
"Cookie": cookie,
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
}
}, function(err, httpResponse, body) {
request({
// will be ignored
method: 'GET',
uri: httpResponse.headers['location'],
followRedirect: false,
headers: {
"Cookie": cookie,
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
}
}, function(err, httpResponse, body) {
console.log(httpResponse, body)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment