Use phantomjs to generate website snapshots-PHP source code

Source: Internet
Author: User
I used phantomjs to generate a website snapshot. yesterday () I saw a code for generating a site snapshot in the code area. after reading the code for half a day, I found that the author only posted the business code, the code for generating snapshot images at the core is not provided. I used to remember the fact that google search provided site thumbnails. at that time, it was amazing, but it didn't take time to do in-depth research. I met again yesterday, so let's investigate it by the way.

Wkhtmltopdf is found at http://code.google.com/p/wkhtmlto /. This tool set has a wkhtmltoimage that can be used to generate site snapshots. Started running on the xen virtual machine, the operating system is centos, all kinds of problems, tossing to the end has not been tossing.
Later, I saw an article by a foreigner, and found that wkhtmltoimage does not support the system running the xen virtual machine. for details, refer to this article: Ghost.

I gave up wkhtmltoimage and continued to find phantomjs and slimerjs. both of them are server-side js. in simple understanding, they all encapsulate the browser parsing engine. The difference is that phantomjs encapsulates webkti, slimerjs encapsulates Gecko (firefox ). Weigh the pros and cons and decide to study phantomjs, so we use phantomjs to generate website snapshots. Phantomjs project address is: http://phantomjs.org/

The code involves two parts: index. php for business design, and snapshot. js for generating snapshots. The code is relatively simple. it only implements functions without too much modification. The code is as follows:

Index. php

 
 
 
 
 Snapshot generation

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.