是这样,题主想把雪球上的文章按html格式转成pdf,看到了有个很方便的pdfkit
结果是这样,pdf是转出来了,但有点格式上的错误
>>> import pdfkit
>>> pdfkit.from_url('http://xueqiu.com/9320604669/53827976', 'out.pdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\pdfkit\api.py", line 24, in from_url
return r.to_pdf(output_path)
File "C:\Python34\lib\site-packages\pdfkit\pdfkit.py", line 109, in to_pdf
if 'cannot connect to X server' in stderr.decode('utf-8'):
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 2362: inval
id start byte
直接用wkhtmltopdf试试
D:\>wkhtmltopdf
http://xueqiu.com/9320604669/53827976 out.pdf
Loading pages (1/6)
QWin32PrintEngine::initialize: OpenPrinter failed (RPC ????????á?)%
QWin32PrintEngine::initialize: OpenPrinter failed (RPC ????????á?)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: UnknownContentError
求问广大V友这是什么问题?