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

查看:135
本文介绍了用于创建网站屏幕截图的命令行程序(在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, ...).

推荐答案

更多细节可能有用...

A little more detail might be useful...

在控制台或使用vncserver的X会话中启动Firefox(或其他浏览器).您可以使用--height--width选项将窗口的大小设置为全屏.另一个firefox命令可用于设置在第一个firefox窗口中显示的URL.现在,您可以使用以下命令之一来抓取屏幕图像,例如Imagemagick软件包中的"import"命令,或者使用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天全站免登陆