> >

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.
  • 1
  • 2
  • 3
  • 4

prev:no prev next:no next
post comments
Notice



Approved   The domain name stolen and retrieved...   "Silly" old lady Ding Ruiyun: promis...   She is a former world champion, maki...   He was a high student at Yale, but h...   Eight couples in Ji'nan join hands i...
rand   Fourteen experiences in programming ...   Using JSON to implement cross domain...   PHP good verification code   PHP upload file code, suitable for b...   Install.php simple production
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