创建网站截图的命令行程序(在 Linux 上) [英] Command line program to create website screenshots (on Linux)

查看:22
本文介绍了创建网站截图的命令行程序(在 Linux 上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Linux 上创建网站屏幕截图的好命令行工具是什么?我需要在没有人工交互的情况下自动生成网站截图.我发现的唯一工具是 khtml2png,但我想知道是否还有其他工具不是基于 khtml (即有很好的 JavaScript 支持,...).

What is a good command line tool to create screenshots of websites on Linux? I need to automatically generate screenshots of websites without human interaction. The only tool that I found was khtml2png, but I wonder if there are others that aren't based on khtml (i.e. have good JavaScript support, ...).

推荐答案

多一点可能有用...

在 X 会话中启动 firefox(或其他浏览器),无论是在您的控制台上还是使用 vncserver.您可以使用 --height--width 选项将窗口的大小设置为全屏.另一个 firefox 命令可用于设置在第一个 Firefox 窗口中显示的 URL.现在,您可以使用多个命令之一抓取屏幕图像,例如 Imagemagick 包中的导入"命令,或者使用 gimp、fbgrab 或 xv.

Start a firefox (or other browser) in an X session, either on your console or using a vncserver. You can use the --height and --width options to set the size of the window to full screen. Another firefox command can be used to set the URL being displayed in the first firefox window. Now you can grab the screen image with one of several commands, such as the "import" command from the Imagemagick package, or using gimp, or fbgrab, or xv.

#!/bin/sh

# start a server with a specific DISPLAY
vncserver :11 -geometry 1024x768

# start firefox in this vnc session
firefox --display :11

# read URLs from a data file in a loop
count=1
while read url
do
    # send URL to the firefox session
    firefox --display :11 $url

    # take a picture after waiting a bit for the load to finish
    sleep 5
    import -window root image$count.jpg

    count=`expr $count + 1`
done < url_list.txt

# clean up when done
vncserver -kill :11

这篇关于创建网站截图的命令行程序(在 Linux 上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆