Use of iojs's jsdom library to synchronize system time

Source: Internet
Author: User

Use of iojs's jsdom library to synchronize system time

This article is to share with you the use of iojs jsdom library and http://open.baidu.com/special/time/ synchronization system time. The idea is very clear. We recommend it to you here. If you need it, you can refer to it.

Use the iojs jsdom library to synchronize system time with the http://open.baidu.com/special/time.

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

Var jsdom = require ("jsdom ");

Var exec = require('child_process'cmd.exe c;

 

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 );

 

// Update the system time

Exec ('time' + curtime, function (err, stdout, stderr ){

Console. log ('change time' + curtime + ':' + (err? Err: 'success '));

Process. exit ();

});

}

});

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.