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


問題描述

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

I would like to generate a screenshot thumbnail of any given url using strictly javascript.  If this can't be done can anyone point me in the right direction to do this with my own api?

edit I just decided to cheat and use frames because it was for something I was doing for fun anyway, but thanks for all the great answers khtmltox is probably the best choice if you want to do something like this... they also have php bindings aswell.


參考解法

方法 1:

If you look at wkhtmltox, there's native lib/app for converting a webpage to an image.

<?php // file: img.php
    $img=render_image($_GET['url']);
?>


<!-- Your Website -->

<img alt='ldr'/>

<script type="text/javascript">
    $(document).ready(function(){
        var url='http://google.com/';
        $('#img').attr('src','img.php?url='+encodeURIComponent(url));
    });
</script>

In case the comment wasn't clear enough, you need PHP somewhere which could run a native program.

方法 2:

There is absolutely zero chance to do that with Javascript. 

Actually, there isn't a chance at all to accomplish that with any "web"'ish technique. There might be a funky flash-app, I don't know (if that exists, one more reason to hate flash :p).

方法 3:

Not gonna happen. The ONLY way you MIGHT be able to do this with JS is if the site is hosted on YOUR server and you have JS trigger to some shell script that renders the users page on your local server and saves it as an image. 

You want a subscription to browser shots

方法 4:

There is no way to do this in Javascript.

I believe this can be done via server-side using third-party software. Have a look at this tutorial for more info.

方法 5:

Bit old, but I faced the same problem and found http://html2canvas.hertzen.com/

(by TylerChristianjAndysethvargonapsterJonathan de M.)

參考文件

  1. generating a screenshot of a website using jquery (CC BY-SA 3.0/4.0)

#screenshot #jquery #PHP #thumbnails






相關問題

沒有 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)







留言討論