如何使用服務器端腳本生成網頁的屏幕截圖? (How can I generate a screenshot of a webpage using a server-side script?)


問題描述

如何使用服務器端腳本生成網頁的屏幕截圖? (How can I generate a screenshot of a webpage using a server-side script?)

I need a server-side script (PHP, Python) to capture a webpage to a PNG, JPG, Tiff, GIF image and resize them to a thumbnail.

What is the best way to accomplish this?

See also:

  • Web Page Screenshots with PHP?
  • How can I take a screenshot of a website with PHP and GD?
  • How might I obtain a Snapshot or Thumbnail of a web page using PHP?
----- ## 參考解法 #### 方法 1:

You can probably write something similar to webkit2png, unless your server already runs Mac OS X.

UPDATE: I just saw the link to its Linux equivalent: khtml2png

See also:

  • Create screenshots of a web page using Python and QtWebKit
  • Taking automated webpage screenshots with embedded Mozilla

方法 2:

What needs to happen is for a program to render the page and then take an image of the page. This is a very slow and heavy process but it can be done in PHP on Windows.

Also check the comments in the documentation article.

For python I'd recommend reading this article. It highlights some of the solutions.

There are services you can also call (via some API) that will return you an image. But usually they cost (WebShots for example)

方法 3:

You'll need to:

  • read the webpage and all the its multimedia content (images, flash, etc)
  • utilize a browser rendering engine to render the webpage
  • take a screenshot and save it as image

first and third steps are easy, the second step is more challenging ;)

方法 4:

If you are using php, you could use imagegrabscreen (PHP 5 >= 5.2.2). Imagegrabscreen: captures the whole screen.

(by ColargolCan Berk GüderÓlafur WaageAzizFrank Vielma)

參考文件

  1. How can I generate a screenshot of a webpage using a server-side script? (CC BY-SA 3.0/4.0)

#screenshot #Python #PHP #server-side-scripting






相關問題

沒有 iPhone,如何使用 XCode 截屏? (Without iPhone, how to take screenshot with XCode?)

mapViewDidFinishLoadingMap:調用過早 (mapViewDidFinishLoadingMap: called too early)

屏幕截圖上的窗口沒有消失 (Window not disappearing on Screenshot)

Appium 中用於混合應用程序的多個屏幕截圖 (Multiple Screenshots in Appium for Hybrid Apps)

在Linux上通過Python腳本拍攝屏幕截圖 (Take a screenshot via a Python script on Linux)

如何使用服務器端腳本生成網頁的屏幕截圖? (How can I generate a screenshot of a webpage using a server-side script?)

如何使用 ruby 和 unix 服務器截取網頁截圖? (How do I take screenshots of web pages using ruby and a unix server?)

使用 jquery 生成網站的屏幕截圖 (generating a screenshot of a website using jquery)

畫面區域的選擇 (Selection of screen area)

使用 PHP 的網頁截圖? (Web Page Screenshots with PHP?)

iPhone:如何在使用 3d 圖層轉換時以編程方式拍攝屏幕截圖 (iPhone: how to take screen shots programmatically when using 3d layer transformations)

防止 VideoView Activity 中的視頻屏幕截圖 - Android (Prevent Video screen capture in VideoView Activity - Android)







留言討論