开发者

What is the way to programmatically render a website to an image from a server environment?

I would like to render websites to an image (JPEG, PNG, PDF, etc.) from a server environment. I have seen a few 开发者_Python百科implementations that use Xvfb but would like to see if there are any decent implementations that would work standalone without X of any sort.

Google Fast Flip seems to do a pretty decent job. I have seen this on a smaller scale where mousing over links pops up a "preview" of the page the link connects to.


I've successfully used wkhtmltopdf to convert web pages to PDF, which I then convert to images. It's built on top of WebKit.


Back in 2006, I rolled my own version of Webshots using a combination of X, VNCServer, Firefox, PHP, and a few shell scripts. It was somewhat of a hack, but worked extremely well.

I don't see how you're going to do this without using some type of GUI environment. The webpage has to be rendered somehow for a screenshot to be captured. Alternatively, use one of the several commercial solutions that offer an API.


Sites like browsershots will do it by loading the webpage into a browser in a VM, then taking a screenshot of the VM environment.

If you have a small number of sites which need snapshots stored, the solutions you linked to should be fine. Otherwise, if you need shots of any/all arbitrary websites, you may want to consider using an existing third-party database of snapshots.


CutyCapt by Björn Höhrmann is excellent - cross platform, built on webkit, outputs to different file formats e.g. PNG / JPEG / PDF.

Usage: CutyCapt --url=http://www.example.org/ --out=localfile.png

Simples :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜