Created
March 22, 2017 05:01
-
-
Save EnixCoda/44fcd4bfc6d445519bf978f0cde4f56d to your computer and use it in GitHub Desktop.
ECNU宿舍电量查询脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
const options = { | |
host: 'wx.ecnu.edu.cn', | |
path: '/CorpWeChat/card/dogetEle.html', | |
method: 'POST', | |
headers: { | |
'X-Requested-With': 'XMLHttpRequest', | |
'Content-Type': 'application/x-www-form-urlencoded' | |
} | |
} | |
const request = http.request(options, response => { | |
response.setEncoding('utf8') | |
response.on('data', data => { | |
console.log(JSON.parse(data)) | |
}) | |
}).on('error', err => console.log(err)) | |
const formData = { | |
area: 'zb', // 中北/闵行 >> zb/mh | |
point: '05101' // 宿舍房间编号,如 五舍101 >> 05101 | |
} | |
const formlize = obj => Object.keys(obj).map(key => `${key}=${obj[key]}`).join('&') | |
request.end(formlize(formData)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment