Google chrome 使用Chrome/Chrome无头模式时如何使用地址栏?

Google chrome 使用Chrome/Chrome无头模式时如何使用地址栏?,google-chrome,screenshot,chromium,headless,Google Chrome,Screenshot,Chromium,Headless,当我使用Google Chrome或Chrome的无头模式拍摄屏幕截图时,它只需要HTML正文 $ chromium --headless --disable-gpu --screenshot --window-size=1280,1080 https://stackoverflow.com/ 为了方便起见,我想用地址栏截图。。。 当我看到这张图片时,我从不混淆“我使用了哪个URL?” 使用Chrome/Chrome headless模式时,如何使用地址栏拍摄屏幕截图?Chrome headl

当我使用Google Chrome或Chrome的无头模式拍摄屏幕截图时,它只需要HTML正文

$ chromium --headless --disable-gpu --screenshot --window-size=1280,1080 https://stackoverflow.com/
为了方便起见,我想用地址栏截图。。。 当我看到这张图片时,我从不混淆“我使用了哪个URL?”


使用Chrome/Chrome headless模式时,如何使用地址栏拍摄屏幕截图?

Chrome headless没有用户界面,它只是在内存中进行渲染,然后在页面加载到缓冲区后,使用该渲染提供屏幕截图。 因此,没有办法让它脱离无头铬功能

但问题在于其他方面。例如,在linux上,您可以使用以下命令(ImageMagick也可以在其他操作系统下工作):

它使用提供的文本向图像添加标题。 因此,很容易将其封装到单个shell脚本中。比如:

#/bin/bash

url=$1

google-chrome --headless --disable-gpu --screenshot "$url"

current_time=$(date "+%Y.%m.%d-%H.%M.%S")
new_fileName=screenshot_$current_time.png

convert screenshot.png -background black -fill white -splice 0x20 -annotate +15+15 $url -gravity North -pointsize 30 $new_fileName

并将其用作
/take_screenshot.shhttp://google.com

显示器的这一部分由操作系统及其界面控制。Chrome无法控制。谢谢,我理解。我要试试Xvfb。太好了!这个脚本完全帮助了我。。。谢谢
#/bin/bash

url=$1

google-chrome --headless --disable-gpu --screenshot "$url"

current_time=$(date "+%Y.%m.%d-%H.%M.%S")
new_fileName=screenshot_$current_time.png

convert screenshot.png -background black -fill white -splice 0x20 -annotate +15+15 $url -gravity North -pointsize 30 $new_fileName