Skip to content

Instantly share code, notes, and snippets.

@EnixCoda
Created March 22, 2017 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnixCoda/44fcd4bfc6d445519bf978f0cde4f56d to your computer and use it in GitHub Desktop.
Save EnixCoda/44fcd4bfc6d445519bf978f0cde4f56d to your computer and use it in GitHub Desktop.
ECNU宿舍电量查询脚本
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