如何截取指定网站的截图?

发布于 2024-08-08 03:52:10 字数 173 浏览 3 评论 0原文

如果我有 google fastflip 等网站的网址列表,我想知道捕获屏幕截图的技术。此类任务需要什么技术或技巧。如果这项技术可以在 Rails 中使用那就太好了。

谢谢

I want to know technique to capture screenshot if I have a url list of those sites like google fastflip. What technology or techniques require for this kind of task. If this technique available in rails it would be great.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

红衣飘飘貌似仙 2024-08-15 03:52:10

为此,您需要一个 HTML 渲染引擎
最简单的方法是使用浏览器插件来完成该任务。

看看这个:创建网站屏幕截图的 15 种方法

You'll need a HTML rendering engine for that.
The easy way is to use a browser plugin for that task.

Check out this: 15 Ways To Create Website Screenshots

┈┾☆殇 2024-08-15 03:52:10

我一直在使用这个优秀的 Firefox 插件 Grab Them All https://addons.mozilla .org/en-US/firefox/addon/7800/ 这是作者同样优秀的 Screengrab 插件的一个版本。

全部抓取允许您将浏览器指向 URL 列表,然后将在指定目录中为您生成所有屏幕截图。它适用于大多数网站。

不过,我正在尝试生成 Google 地图 URL 的屏幕截图,但目前对我来说不起作用,因为这些页面不是标准页面 - 它们使用框架等。但对于大多数用途来说,上述内容都很棒 - 超级快速且易于设置。希望有帮助。

I have been using this excellent Firefox plugin Grab Them All https://addons.mozilla.org/en-US/firefox/addon/7800/ which is a version of the author's also excellent Screengrab add on.

Grab them All allows you to point the browser at a list of URLs and then will produce all the screenshots for you in a specified directory. It works brilliant with most websites.

However I am trying to generate screenshots of Google Maps URLS which is not working for me at the moment because the pages are not standard pages - they use frames etc. But for most purposes the above is great - super quick and easy to set up. Hope that helps.

莳間冲淡了誓言ζ 2024-08-15 03:52:10

嘿,我正在使用无头网络浏览器和 Xvfb。首先,安装软件包依赖项,例如 Ubuntu:

sudo apt-get install xvfb imagemagick x11-apps

然后使用 sudo 对某些“无人用户”运行下面的 shellcript,如下所示:

/usr/bin/sudo -u nobody /path/screengrab.sh www.ibm.com 34344 >>/tmp/screengrab.log 2>&1

您可能需要调整裁剪等。

#!/bin/bash

rm -rf /home/nobody/.mozilla/

XAUTHORITY=

Xvfb :$2 -pixdepths 32 -screen 0 1024x1024x24 >/dev/null 2>&1 &
XPID=$!

sleep 1

firefox -width 2000 -height 1024 --display :$2 http://$1 &
FPID=$!

sleep 6
xwd -display :$2 -root -out /tmp/$2-$.xwd

convert /tmp/$2-$.xwd /u0/screengrabs/$1.png # Cache
convert -resize 300x300 /tmp/$2.xwd /tmp/$2-$.png
convert -crop 287x248+0+29 /tmp/${2}-$.png /tmp/${2}2-$.png

mkdir -p /home/je/www/domaintool.se/docs/images/$1
cp /tmp/${2}2-$.png /home/je/www/domaintool.se/docs/images/$1/`date +%Y%m%d`.png
rm -f /tmp/$2-$.png /tmp/$2-$.xwd /tmp/${2}2-$.png

kill $XPID >/dev/null 2>&1
kill $FPID >/dev/null 2>&1

Hey, i'm using a headless webbrowser and Xvfb. First, install the package dependencies for example Ubuntu:

sudo apt-get install xvfb imagemagick x11-apps

Then run the shellcript below using sudo to some "nobody user", like this:

/usr/bin/sudo -u nobody /path/screengrab.sh www.ibm.com 34344 >>/tmp/screengrab.log 2>&1

You might need to adjust the cropping etc.

#!/bin/bash

rm -rf /home/nobody/.mozilla/

XAUTHORITY=

Xvfb :$2 -pixdepths 32 -screen 0 1024x1024x24 >/dev/null 2>&1 &
XPID=$!

sleep 1

firefox -width 2000 -height 1024 --display :$2 http://$1 &
FPID=$!

sleep 6
xwd -display :$2 -root -out /tmp/$2-$.xwd

convert /tmp/$2-$.xwd /u0/screengrabs/$1.png # Cache
convert -resize 300x300 /tmp/$2.xwd /tmp/$2-$.png
convert -crop 287x248+0+29 /tmp/${2}-$.png /tmp/${2}2-$.png

mkdir -p /home/je/www/domaintool.se/docs/images/$1
cp /tmp/${2}2-$.png /home/je/www/domaintool.se/docs/images/$1/`date +%Y%m%d`.png
rm -f /tmp/$2-$.png /tmp/$2-$.xwd /tmp/${2}2-$.png

kill $XPID >/dev/null 2>&1
kill $FPID >/dev/null 2>&1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文