diff --git a/qutebrowser/misc/mhtml.py b/qutebrowser/misc/mhtml.py
index 1266fb6a3..2d8a5e069 100644
--- a/qutebrowser/misc/mhtml.py
+++ b/qutebrowser/misc/mhtml.py
@@ -182,83 +182,108 @@ class MHTMLWriter(object):
fp.write(b"\r\n\r\n")
+class _Downloader(object):
+
+ """A class to download whole websites."""
+
+ def __init__(self, web_view, dest):
+ self.web_view = web_view
+ self.dest = dest
+ self.writer = MHTMLWriter()
+ self.loaded_urls = set()
+ self.pending_downloads = set()
+
+ def run(self):
+ """Download and save the page.
+
+ The object must not be reused, you should create a new one if
+ you want to download another page.
+ """
+ download_manager = objreg.get("download-manager", scope="window",
+ window="current")
+ web_url_str = self.web_view.url().toString()
+ web_frame = self.web_view.page().mainFrame()
+
+ self.writer.root_content = web_frame.toHtml().encode("utf-8")
+ self.writer.content_location = web_url_str
+ # I've found no way of getting the content type of a QWebView, but
+ # since we're using .toHtml, it's probably safe to say that the
+ # content-type is HTML
+ self.writer.content_type = 'text/html; charset="UTF-8"'
+ # Currently only downloading (stylesheets),