Html 将网页转换为图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/968201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert web page to image
提问by jrharshath
What are some utilities to obtain an image of a webpage?
获取网页图像的一些实用程序是什么?
Basically equivalent to taking a "screenshot" of the page after opening it.
基本上相当于打开页面后对页面进行“截图”。
采纳答案by Stobor
Real answers:
真实答案:
http://cutycapt.sourceforge.net/
http://cutycapt.sourceforge.net/
http://iecapt.sourceforge.net/
http://iecapt.sourceforge.net/
http://www.websitescreenshots.com/
http://www.websitescreenshots.com/
http://khtml2png.sourceforge.net/
http://khtml2png.sourceforge.net/
https://htmlcsstoimage.com/(Uses Google Chrome)
https://htmlcsstoimage.com/(使用谷歌浏览器)
https://gofullpage.com/- Full Page Screen Capture (Chrome extension) - see this superuser answer for more info
https://gofullpage.com/- 整页屏幕截图(Chrome 扩展程序)-有关详细信息,请参阅此超级用户答案
(Don't know of one to use Mozilla's renderer, though.)
(不过,不知道有没有人使用 Mozilla 的渲染器。)
回答by PiX
Awesome : http://wkhtmltopdf.org/
wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the QT Webkit rendering engine.
wkhtmltopdf 和 wkhtmltoimage 是开源 (LGPLv3) 命令行工具,可使用 QT Webkit 渲染引擎将 HTML 渲染为 PDF 和各种图像格式。
回答by Jim Puls
Somebody wrote a blog post about thisa few years back. There are examples in several languages, using both WebKit and Mozilla. There's also an example in Ruby.
几年前有人写了一篇关于这个的博客文章。有几种语言的示例,使用 WebKit 和 Mozilla。在 Ruby 中也有一个例子。
It boils down to this: decide how wide you want your window to be; put a browser component in the window; wait until the page loads; capture the pixel buffer contents.
归结为:决定你希望你的窗户有多宽;在窗口中放置一个浏览器组件;等待页面加载;捕获像素缓冲区内容。
回答by Aftershock
http://code.google.com/p/wkhtmltopdf/again..
再次http://code.google.com/p/wkhtmltopdf/..
Somebody mentioned this already.. I will write about it in more detail...
已经有人提到了……我会写得更详细……
Contrary to what the name implies, there is html page to image converter as well.
It supports png and jpeg.
One can modify the user agent string of all requested urls and minimum width and height of the webpage.
It is possible to add new headers and set it for all requests.
It works on Windows and Linux.
It can ignore webpage errors.
It uses Webkit and Qt library. It installs easily, no additional libaries are needed
(everything is included in the distribution).
It is free and regularly updated. There are binaries available for both Linux and Windows.
It can handle flash on Windows. (It may do so on Linux as well, untested)
与名称所暗示的相反,还有 html 页面到图像转换器。
它支持 png 和 jpeg。
可以修改所有请求的url的用户代理字符串和网页的最小宽度和高度。
可以添加新标头并为所有请求设置它。
它适用于 Windows 和 Linux。
它可以忽略网页错误。
它使用 Webkit 和 Qt 库。它易于安装,不需要额外的库
(所有内容都包含在发行版中)。
它是免费的并定期更新。有适用于 Linux 和 Windows 的二进制文件。
它可以处理 Windows 上的闪存。(它也可以在 Linux 上这样做,未经测试)
回答by marknt15
Using Firefox, you will need the screengrab addon.
使用 Firefox,您将需要 screengrab 插件。
回答by null
You can also use "gnome-web-photo" as a command line tool to screenshot a webpage.
您还可以使用“gnome-web-photo”作为命令行工具来截取网页。
回答by Colin Coghill
I'm not sure if this is quite what you're looking for but I've had a lot of success using an HTML to Postscript converter html2psto create postscript copies of web pages, which I then convert to .gif or .pngs
我不确定这是否正是您正在寻找的内容,但我使用 HTML 到 Postscript 转换器html2ps创建网页的 postscript 副本取得了很大的成功,然后我将其转换为 .gif 或 .pngs
This doesn't produce exact screenshot quality that you'd get from a web browser and doesn't handle complicated things like flash or css all that well, but the advantage is that you can run it on the web server.
这不会产生您从 Web 浏览器获得的精确屏幕截图质量,也不能很好地处理诸如 flash 或 css 之类的复杂事物,但优点是您可以在 Web 服务器上运行它。
(I use it to create thumbnails of user created content, for navigation)
(我用它来创建用户创建内容的缩略图,用于导航)
回答by melnaron
Give it a try: http://convertwebpage.com— this is a web-application that can convert web-pages into images (jpg, png) or into pdf and has some options.
试试看:http: //convertwebpage.com— 这是一个网络应用程序,可以将网页转换为图像(jpg、png)或 pdf,并有一些选项。
回答by wai
Not sure if this is what you want but this is what I do sometimes in a pinch when certain websites are not saving right.
不确定这是否是您想要的,但是当某些网站没有正确保存时,这就是我有时会做的事情。
I just print them to PDF and I get a PDF file of the 'print output'. There's an Microsoft XPS Document writer under my list of printers as well, but I don't use it.
我只是将它们打印为 PDF,然后得到一个“打印输出”的 PDF 文件。在我的打印机列表下也有一个 Microsoft XPS Document writer,但我不使用它。
Hope this helps! =)
希望这可以帮助!=)
回答by kylex
You could use imagemagick and write a script that fires everytime you load a webpage.
您可以使用 imagemagick 并编写一个每次加载网页时都会触发的脚本。