使用chrome从URL获取PDF
项目描述
# Chrome-PrintToPDF
最新版的Chrome浏览器支持获取网站的PDF文件。
## 安装
需要Python 3.5+
pip install chrome-printtopdf
## 使用方法
在命令行中
python -m chrome_printtopdf /path/to/chrome-bin http://example.org/ out.pdf
作为库。请查看源代码了解`asyncio` API。
```python
from chrome_printtopdf import get_pdf_with_chrome_sync
pdf_file = get_pdf_with_chrome_sync('http://example.org',
chrome_binary='/path/to/chrome-bin')
with open('example.org.pdf', 'wb') as f
f.write(pdf_file.read())
```
最新版的Chrome浏览器支持获取网站的PDF文件。
## 安装
需要Python 3.5+
pip install chrome-printtopdf
## 使用方法
在命令行中
python -m chrome_printtopdf /path/to/chrome-bin http://example.org/ out.pdf
作为库。请查看源代码了解`asyncio` API。
```python
from chrome_printtopdf import get_pdf_with_chrome_sync
pdf_file = get_pdf_with_chrome_sync('http://example.org',
chrome_binary='/path/to/chrome-bin')
with open('example.org.pdf', 'wb') as f
f.write(pdf_file.read())
```