使用iojs的jsdom庫實現(xiàn)同步系統(tǒng)時間
更新時間:2015年04月20日 14:24:58 投稿:hebedich
本文給大家分享的是使用iojs的jsdom庫實現(xiàn)與http://open.baidu.com/special/time/ 同步系統(tǒng)時間。思路非常的清晰,這里推薦給大家,有需要的小伙伴可以參考下。
使用iojs的jsdom庫與 http://open.baidu.com/special/time/ 同步系統(tǒng)時間。
var jsdom = require("jsdom"); var exec = require('child_process').exec; jsdom.env({ url: "http://open.baidu.com/special/time/", scripts: ["D:\\jquery-1.9.1.min.js"], features: { ProcessExternalResources: ["script"] }, done: function (errors, window) { var $ = window.$; var curtime = $('#time').text(); console.log('get time: ' + curtime); // 更新系統(tǒng)時間 exec('time ' + curtime, function(err, stdout, stderr) { console.log('change time ' + curtime + ': ' + (err ? err : 'success')); process.exit(); }); } });
以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。
相關(guān)文章
node.js模擬實現(xiàn)自動發(fā)送郵件驗證碼
這篇文章主要為大家介紹了node.js模擬實現(xiàn)自動發(fā)送郵件驗證碼的實例過程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-04-04node.js中fs.stat與fs.fstat的區(qū)別詳解
fs.stat和fs.fstat他們都是用來獲取文件的狀態(tài)信息,下面這篇文章主要給大家介紹了關(guān)于node.js中fs.stat與fs.fstat區(qū)別的相關(guān)資料,文中介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。2017-06-06