Curl http://xxx.com/address/addresslist\?search\=%40--cookie oa_cookie=123 -s| node parss.js
JS Code
varJsdom = require ('Jsdom'), FS= Require ('FS') process.stdin.setEncoding ('UTF8');varHTML ="'Process.stdin.on ('readable', function () {varChunk =Process.stdin.read (); if(Chunk!==NULL) HTML + =chunk});varUserList = require ('./userlist.json'), Userhash=Json.parse (Json.stringify (userlist)) Process.stdin.on ('End', function () {Process.stdout.write ('\ n'); Jsdom.env (HTML, function (errors, window) {varList = [] varL = Window.document.querySelectorAll ('#userlist TR') for(vari =0; i < l.length; i + + ){ varLi = L[i].getelementsbytagname ('TD') if(!li | | Li.length <8)Continue varuser_id = li[0].textcontentvaruser = { "name": li[2].textcontent,"DEP": li[4].textcontent,"Email": li[3].textcontent,"Phone": li[6].textcontent,"QQ": li[7].textcontent.trim ()}if(user_idinchuserlist) {Delete userhash[user_id]Continue} user.join= +NewDate () userlist[user_id]=User Process.stdout.write ('\ n Entry:'+json.stringify (user)} varQuits =json.stringify (Userhash)if('{}'!=quits) { varleaves = quires ('./leaves.json') for(varIdinchUserhash) {Leaves[id]=Userhash[id]} fs.writefile ('./leaves.json', Json.stringify (leaves,NULL,4)) Process.stdout.write ('\ nthe resignation:'+quits)} Fs.writefile ('./userlist.json', Json.stringify (UserList,NULL,4)) Process.stdout.write ('\nend'); } )})
Jsdom official website Https://github.com/tmpvar/jsdom