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