Web Page Screenshots with PHP?

后端 未结 6 826
谎友^
谎友^ 2020-12-20 22:14

I know there is not a direct way to take a screen shot of a web page with PHP. What would be the most straightforward way to accomplish this? Are there any command line tool

相关标签:
6条回答
  • 2020-12-20 22:50

    See webkit2png for an OSX commandline program that does this.

    The page also mentions Linux alternatives.

    [edit]: wkhtml2image is the newest kid in town, and it works better then anything else i've ever used.

    [edit2]: As of 2014, PhantomJS seems to be the way to go, as it has the newest webkit version of the alternatives I know about.

    [edit3]: In 2019, Puppeteer is the way to go. Official headless chrome, always up to date.

    0 讨论(0)
  • 2020-12-20 23:02

    html2ps does a decent job for relatively simple pages, and it requires very little in terms of external binaries, meaning it's very easy to install/use. If you control the pages you'll be capturing, then you can ensure that they'll render appropriately in html2ps. If you're hoping to capture arbitrary URLs, however, I'm not sure that the PHP port of HTML2PS is up to the task. It's also not the fastest thing in the world (expect render times in the seconds for complex pages), but that doesn't really matter for some applications.

    0 讨论(0)
  • 2020-12-20 23:04

    You can use the GD functions imagegrabscreen() or imagegrabwindow() to take a screenshot, but they're only available on Windows at the moment.

    0 讨论(0)
  • 2020-12-20 23:09

    http://www.thumbshots.org/

    0 讨论(0)
  • 2020-12-20 23:09

    Not sure if this would be enough for you, because it has some added stuff there, but would be worth giving it a try: http://www.snap.com

    0 讨论(0)
  • 2020-12-20 23:09

    It's possible to get a base64 encoded image of a site by using the Google pagespeed api. You can specify desktop or mobile views, but you are limited to an image of a certain size.

    0 讨论(0)
提交回复
热议问题