I want to convert html files created with Folium to png to finally convert them in a single gif.
I'm stuck on converting html to images. I've tried so far (on Colab):
Code1:
!pip install selenium
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
wd.get("https://www.webite-url.com")
import os
import imageio
import webbrowser
Error1:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Code 2:
import os
import subprocess
url="osm1.html"
outfn = "outfig.png"
subprocess.check_call(["{}".format(url), "--out={}".format(outfn)])
Error2:
FileNotFoundError: [Errno 2] No such file or directory: 'osm1.html': 'osm1.html'
(osm1.html is in the root of Colab)
Code 3:
!pip install bokeh
import bokeh
from bokeh.io import export_png
url="osm1.html"
export_png(url, filename="plot.png")
Error3:
ValueError: OutputDocumentFor expects a sequence of Models
Code 4:
!pip install imgkit
!apt-get install xvfb
!apt-get install wkhtmltopdf
import imgkit
imgkit.from_file('osm1.html', 'out.jpg')
Error4:
OSError: wkhtmltoimage exited with non-zero code 1. error:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
You need to install xvfb(sudo apt-get install xvfb, yum install xorg-x11-server-Xvfb, etc), then add option: {"xvfb": ""}.
Any of the solution above can be easily solved? I don't know more ways to do it.