需要认证的网站¶
如果你想截取需要某种形式认证的网站的屏幕截图,你需要先手动在该网站上进行认证。
你可以使用 shot-scraper auth
命令来完成此操作
shot-scraper auth \
https://datasette-auth-passwords-demo.datasette.io/-/login \
auth.json
(对于此演示,使用用户名 = root
和密码 = password!
)
这将在你的计算机上打开一个浏览器窗口,显示你指定的页面。
然后你可以使用该浏览器窗口进行登录 - 包括双因素认证 (2FA)、验证码 (CAPTCHA) 或其他更复杂的认证形式。
完成后,在 shot-scraper
命令行提示符下按 <enter>
。浏览器将关闭,该浏览器会话的认证凭据(通常是 cookie)将写入 auth.json
文件。
然后,要截取经过认证的屏幕截图,你可以使用 -a
或 --auth
选项指向你创建的 JSON 文件
shot-scraper https://datasette-auth-passwords-demo.datasette.io/ \
-a auth.json -o authed.png
shot-scraper auth --help
¶
shot-scraper auth
的完整 --help
信息
Usage: shot-scraper auth [OPTIONS] URL CONTEXT_FILE
Open a browser so user can manually authenticate with the specified site, then
save the resulting authentication context to a file.
Usage:
shot-scraper auth https://github.com/ auth.json
Options:
-b, --browser [chromium|firefox|webkit|chrome|chrome-beta]
Which browser to use
--browser-arg TEXT Additional arguments to pass to the browser
--user-agent TEXT User-Agent header to use
--devtools Open browser DevTools
--log-console Write console.log() to stderr
--help Show this message and exit.