PHP combines phantomjs to achieve webpage screenshots and grab JS rendering pages.

time:18-07-19 forum:PHP tools and code
  https://blog.csdn.net/jiedao_liyk/artic... S/78850684

first PhantomJS fast introduction. It fully supports web without browser support, and its fast native support for various Web standards: DOM processing, CSS selector, JSON, Canvas, and SVG. PhantomJS can be used for page automation, network monitoring, web screenshots, and no interface testing.

1, install
install package download address: http://phantomjs.org/download.html, including Windows, versions, self selection of the corresponding release load Antomjs sets the environment variable, which contains a example folder, which contains many written code for use. This article assumes that phantomjs has been installed and environment variables have been set up.

two, use
Hello, World!
create a text file that contains the following two lines of script:

console.log ('Hello, world! ");
phantom.exit ();
save the file as hello.js, and then execute it:

the first line will print the string at the terminal. The second line phantom.exit will exit.
it is very important to call phantom.exit in this script, otherwise PhantomJS will not stop at all.

script parameter - how does Script Arguments
Phantomjs transfer parameters? As shown below:

phantomjs examples/arguments.js foo bar baz
foo, bar, Baz is the parameter to be passed. Br / >} else {
system.args.forEach (function (Arg, I) {
console.log (I ':' ARG);
page loading – page object, a web page by creating a web page Can be loaded, analyzed and rendered.
  • 2
  • 3
  • 4

prev:no prev next:The first 5 enterprises in Ji'nan obtain...
post comment
Notice



approved   A rare picture of the old Ji'nan! Th...   The deep mountain women's back husba...   Sichuan Leshan 84 year old Lao Tai a...   Loss of breast and cancer coexistenc...   The "ship man" in the city: the aver...
rand   The UBB label turns the PHP function...   PHP implements HTML code to UBB Tags   PHP intercepts the class and instanc...   Foreign web design web site construc...   IBM's PHP tutorial article
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com