lzjun567 / python_scripts

一些python相关的演示代码
Apache License 2.0
717 stars 528 forks source link

图片无法下载 #13

Open alexkie007 opened 7 years ago

alexkie007 commented 7 years ago

爬取我想要的代码时 对于网页里的所有图片 全部都是failed to load

ghost commented 7 years ago

我还以为只有我一个人报这个错误哩,原来大家都有这个问题

Traceback (most recent call last): File "crawler.py", line 165, in crawler.run() File "crawler.py", line 99, in run pdfkit.from_file(htmls, self.name + ".pdf", options=options) File "D:\Program Files\Python36\lib\site-packages\pdfkit\api.py", line 49, in from_file return r.to_pdf(output_path) File "D:\Program Files\Python36\lib\site-packages\pdfkit\pdfkit.py", line 156, in to_pdf raise IOError('wkhtmltopdf reported an error:\n' + stderr) OSError: wkhtmltopdf reported an error: Loading pages (1/6) libpng warning: iCCP: extra compressed data==> ] 74% libpng warning: iCCP: extra compressed data====> ] 77% libpng warning: iCCP: extra compressed data====> ] 77% libpng warning: iCCP: extra compressed data====> ] 77% libpng warning: iCCP: extra compressed data====> ] 78% 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: ProtocolUnknownError

alexkie007 commented 7 years ago

我对解决办法是 自己在代码里面加一段 获得图片真实地址后 下载图片到本地 生成pdf后删除图片

xpguan commented 7 years ago

怎么改的? 请赐教

alexkie007 commented 7 years ago

获得图片完整链接后将图片保存在本地 html里的路径都不用改 你按照相应路径保存即可