URL 转 PDF
快速开始
python3 scripts/url_to_pdf.py --url "<URL>" --out /tmp/page.pdf
仅正文(提取指定选择器并重新排版):
python3 scripts/url_to_pdf.py --url "<URL>" --out /tmp/page.pdf --content-selector "#js_content"
依赖安装
python3 -m pip install playwright beautifulsoup4
python3 -m playwright install chromium
或使用内置安装脚本:
./scripts/setup.sh
备注
- 默认开启自动滚动加载懒加载图片;可用
--no-scroll关闭。 - 页面异步渲染时可用
--wait-selector等待特定元素出现。 - 如 Playwright 无法下载浏览器,可使用已安装的 Chrome:
--chrome-path "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"。