the DOM operation, and the debugging process is essential, for those small methods, always appear insufficient. Phantomjs here is a good implementation.
Phantomjs is a non-interface webkit with JavaScript API
As you know, WebKit is the layout engine used by Chrome, Safari, and some other niche browsers. Therefore, PHANTOMJS is a browser and is a browser with no interface. This means that the rendered page is never actually displayed. This may be incredible to you, so you can use it as a programmable browser terminal.
Installing PHANTOMJS
Simple to use
Can write a random JS text
Performed by Phantomjs Xx.js, the results show
There are various method parameters in the API, there is not much to say
Page load
1 var page = require (' webpage '). Create (); 2 page.open ("http://www.baidu.com",function() {3 console.log ("Start ..."); 4 });
The results are as follows
So here's the question. What if there are paths that need to be taken with a parameter, it's not as easy as & in a browser?
It is necessary to introduce system,require (' system ') in this way so as to realize the access of the parameters
1 varpage = require (' webpage '). Create (),2System = require (' System '), address;3 4Address = System.args[1];5Page.open (Address,function(status) {6 if(Status!== ' success ') {7Console.log (' FAIL to load the address ');8}Else {9Console.log (' Loading success! '));Ten } One phantom.exit (); A});
Results
Go down like this today, write a few examples behind!
PHANTOMJS first entry