刚刚想做一个图片,发现这个问题
import imgkit
html = imgkit.from_url(url="https://www.baidu.com",output_path="out.png")
运行后发现报这个错
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/EJU/dealspiders/qiyewecat/demo3.py", line 7, in <module>
html = imgkit.from_url(url="https://www.baidu.com",output_path="out.png")
File "C:\Users\EJU\AppData\Local\Programs\Python\Python36\lib\site-packages\imgkit\api.py", line 31, in from_url
cover_first=cover_first)
File "C:\Users\EJU\AppData\Local\Programs\Python\Python36\lib\site-packages\imgkit\imgkit.py", line 34, in __init__
self.config = Config() if not config else config
File "C:\Users\EJU\AppData\Local\Programs\Python\Python36\lib\site-packages\imgkit\config.py", line 36, in __init__
'http://wkhtmltopdf.org\n'.format(self.wkhtmltoimage))
OSError: No wkhtmltoimage executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - http://wkhtmltopdf.org
一番找解决方式后,把代码改成了
import imgkit
path_wk = r"E:\\software\\wkhtmltopdf\\bin\\wkhtmltoimage.exe"
config = imgkit.config(wkhtmltoimage=path_wk)
html = imgkit.from_url(url="https://www.baidu.com",config=config,output_path="out.png")
然后wkhtmltoimage不报错了,但是xvfb却依然过不去
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/EJU/dealspiders/qiyewecat/demo2.py", line 14, in <module>
config = imgkit.config(wkhtmltoimage=path_wk)
File "C:\Users\EJU\AppData\Local\Programs\Python\Python36\lib\site-packages\imgkit\api.py", line 101, in config
return Config(**kwargs)
File "C:\Users\EJU\AppData\Local\Programs\Python\Python36\lib\site-packages\imgkit\config.py", line 44, in __init__
'read it. Otherwise please install xvfb -'.format(self.xvfb))
OSError: No xvfb executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install xvfb -
求大神指点