在命令行上使用Firefox拍摄整页截图 [英] Take a full page screenshot with Firefox on the command-line

查看:66
本文介绍了在命令行上使用Firefox拍摄整页截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VPS的Xvfb上运行Firefox。我想做的是对该页面进行全屏截图。

I'm running Firefox on a Xvfb in a VPS. What I want to do is to take a full page screenshot of the page.

我可以使用

firefox http://google.com

并使用ImageMagick截屏(在X内)

and take a screenshot (inside X) using ImageMagick

import root -window output.jpg

问题是,大多数页面需要滚动,而我事先不知道高度。

The problem is, most of the page need scrolling and I can't know the height beforehand.

另一种方法是选择一个很大的高度(例如4000px),然后处理图像并删除无用的部分。但这是不必要的处理。

The other way is to pick a very big height (like 4000px) and then process the image and remove the useless part. But that's unnecessary processing.

我发现了许多Firefox附加组件,但我正在寻找可以使用Shell命令行进行编程的解决方案。

I found many Firefox add-ons, but I'm looking for a solution that can be programmed using the Shell Command line.

编辑:我最终编写了自己的 FireFox扩展

I ended up writing my own FireFox extension for doing this.

推荐答案

开发人员工具栏GCLI和 Shift + F2 快捷方式已在Firefox 60版中删除。要使用60或更高版本的屏幕截图:

The Developer Toolbar GCLI and Shift+F2 shortcut were removed in Firefox version 60. To take a screenshot in 60 or newer:


  • Ctrl + Shift + K 打开开发者控制台(在MacOS上为⌥Option + ⌘Command + K
  • b $ b
  • 类型:截屏:截屏-整页

  • press Ctrl+Shift+K to open the developer console (⌥ Option+⌘ Command+K on macOS)
  • type :screenshot or :screenshot --fullpage

查找有关屏幕截图和其他功能的更多信息

对于Firefox版本< 60:

For Firefox versions < 60:

Shift + F2 或转到工具> Web开发人员>开发人员工具栏打开命令行。写入:

Press Shift+F2 or go to Tools > Web Developer > Developer Toolbar to open a command line. Write:

screenshot

,然后按 Enter 即可截屏。

要完全回答问题,您甚至可以保存整个内容页面,不仅是其中的可见部分:

To fully answer the question, you can even save the whole page, not only the visible part of it:

screenshot --fullpage

并将屏幕快照复制到剪贴板,请使用-clipboard 选项:

And to copy the screenshot to clipboard, use --clipboard option:

screenshot --clipboard --fullpage

Firefox 18 更改了将参数传递给命令的方式,您必须

Firefox 18 changes the way arguments are passed to commands, you have to add "--" before them.

您可以找到一些文档和命令的完整列表此处

You can find some documentation and the full list of commands here.

PS。屏幕快照默认情况下保存在 downloads 目录中。

PS. The screenshots are saved into the downloads directory by default.

这篇关于在命令行上使用Firefox拍摄整页截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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