将网页保存为 PDF¶
命令 shot-scraper pdf
将网页保存为 PDF 版本 - 相当于在 Chromium 中使用 Print -> Save to PDF
。
shot-scraper pdf https://datasette.com.cn/
这将保存到 datasette-io.pdf
。你可以使用 -o
来指定文件名
shot-scraper pdf https://datasette.com.cn/tutorials/learn-sql \
-o learn-sql.pdf
你可以传入本地文件路径,而不是 URL
shot-scraper pdf invoice.html -o invoice.pdf
shot-scraper pdf --help
¶
该命令的完整 --help
信息
Usage: shot-scraper pdf [OPTIONS] URL
Create a PDF of the specified page
Usage:
shot-scraper pdf https://datasette.io/
Use -o to specify a filename:
shot-scraper pdf https://datasette.io/ -o datasette.pdf
You can pass a path to a file instead of a URL:
shot-scraper pdf invoice.html -o invoice.pdf
Options:
-a, --auth FILENAME Path to JSON authentication context file
-o, --output FILE
-j, --javascript TEXT Execute this JS prior to creating the PDF
--wait INTEGER Wait this many milliseconds before taking the
screenshot
--wait-for TEXT Wait until this JS expression returns true
--timeout INTEGER Wait this many milliseconds before failing
--media-screen Use screen rather than print styles
--landscape Use landscape orientation
--format [Letter|Legal|Tabloid|Ledger|A0|A1|A2|A3|A4|A5|A6]
Which standard paper size to use
--width TEXT PDF width including units, e.g. 10cm
--height TEXT PDF height including units, e.g. 10cm
--scale FLOAT RANGE Scale of the webpage rendering [0.1<=x<=2.0]
--print-background Print background graphics
--log-console Write console.log() to stderr
--fail Fail with an error code if a page returns an
HTTP error
--skip Skip pages that return HTTP errors
--bypass-csp Bypass Content-Security-Policy
--silent Do not output any messages
--auth-password TEXT Password for HTTP Basic authentication
--auth-username TEXT Username for HTTP Basic authentication
--help Show this message and exit.