PHANTOMJS first entry

Source: Internet
Author: User

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

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.