Last active
December 27, 2015 09:39
-
-
Save wliment/7305377 to your computer and use it in GitHub Desktop.
Node 获取公积金 数据(新疆)(过期,原网站弃用)
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
var fs = require('fs') | |
, http = require('http') | |
, socketio = require('socket.io') | |
, request = require('request') | |
var server = http.createServer(function(req, res) { | |
res.writeHead(200, { 'Content-type': 'text/html'}); | |
res.end(fs.readFileSync(__dirname + '/index.html')); | |
}).listen(8080, function() { | |
console.log('Listening at: http://localhost:8080'); | |
}); | |
socketio.listen(server).on('connection', function (socket) { | |
socket.on('message', function (msg) { | |
console.log('Message Received: ', msg); | |
socket.broadcast.emit('message', msg); | |
}); | |
socket.on('cms', function (msg) {//发送验证码 | |
console.log('cms',msg); | |
db.get_tel(msg, function (tel,code){ | |
send_message(tel,code); | |
} | |
); | |
}); | |
}); | |
function send_message(tel,code){ | |
console.log('send cms: ', "23333333333"); | |
var m="验证码: "+code; | |
request('http://quanapi.sinaapp.com/fetion.php?u='+tel+'&p=ZHENGTAO5655327&to=13899896441&m='+m, function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
console.log(body) | |
} | |
}) | |
} | |
var cookie="";//全局cookie | |
function get_cookie(callback){ | |
if(cookie=="") | |
request( | |
{ | |
method:"GET" , | |
url:"http://www.wlmqgjj.com/hpfp_psn/login.do?method=login", | |
followRedirect: true, | |
maxRedirects: 10 | |
} ,function(error,response,body){ | |
console.log(error) ; | |
console.log(response.statusCode) ; | |
console.log("cookie") ; | |
if (!error && response.statusCode == 200) { | |
cookie=response.headers['set-cookie'][0].split(";")[0] ; | |
var j = request.jar(); | |
console.log("haha "+cookie); | |
cc=request.cookie(cookie); | |
j.add(cc); | |
request( | |
{ | |
method:"GET" , | |
url:"http://www.wlmqgjj.com/hpfp_psn/j_unieap_security_check.do?j_username=web&j_password=wlmq@neusoft", | |
jar:j | |
} ,function(error,response,body){ | |
if (!error && response.statusCode == 200) { | |
a=body ; | |
//b=JSON.stringify(a); | |
//console.log(JSON.parse(b)); | |
callback("123"); | |
} | |
}); | |
} | |
}) | |
} | |
function get_gongjijin(ident_no){ | |
b=JSON.stringify({header:{"code":0,"message":{"title":"","detail":""}},body:{dataStores:{},parameters:{"psnAccOrCertNo":"652322198701084010"}}}); | |
console.log(b); | |
var j = request.jar(); | |
console.log("haha "+cookie); | |
cc=request.cookie(cookie); | |
j.add(cc); | |
request( | |
{ | |
method:"POST" , | |
url:"http://www.wlmqgjj.com/hpfp_psn/psncollquery_psncollacc.do?method=qryPsnCollAccList", | |
body:b, | |
jar:j | |
} ,function(error,response,body){ | |
console.log(response.statusCode) ; | |
console.log("gggggggggg") ; | |
if (!error && response.statusCode == 200) { | |
//console.log(body) | |
a=eval("("+ body+")"); | |
console.log(a.body.dataStores.gridDataStore.rowSet.primary[0]) ; | |
} | |
}); | |
}; | |
conslole.log('gaga'); | |
get_cookie(get_gongjijin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment