'Download and save the page.
The object must not be reused, you should create a new one if
you want to download another page.'

def run(self):

    if self._used:
        raise ValueError('Downloader    already    used')
    self._used = True
    web_url = self.tab.url()
    page = self.tab._widget.page()
    web_frame = page.mainFrame()
    self.writer = MHTMLWriter(web_frame.toHtml().encode('utf-8'), content_location=urlutils.encoded_url(web_url), content_type='text/html;    charset="UTF-8"')
    elements = web_frame.findAllElements('link,    script,    img')
    for element in elements:
        element = webkitelem.WebKitElement(element, tab=self.tab)
        if (not _check_rel(element)):
            continue
        if ('src' in element):
            element_url = element['src']
        elif ('href' in element):
            element_url = element['href']
        else:
            continue
        absolute_url = web_url.resolved(QUrl(element_url))
        self._fetch_url(absolute_url)
    styles = web_frame.findAllElements('style')
    for style in styles:
        style = webkitelem.WebKitElement(style, tab=self.tab)
        if (('type' in style) and (style['type'] != 'text/css')):
            continue
        for element_url in _get_css_imports(str(style)):
            self._fetch_url(web_url.resolved(QUrl(element_url)))
    for element in web_frame.findAllElements('[style]'):
        element = webkitelem.WebKitElement(element, tab=self.tab)
        style = element['style']
        for element_url in _get_css_imports(style, inline=True):
            self._fetch_url(web_url.resolved(QUrl(element_url)))
    self._collect_zombies()
    if ((not self.pending_downloads) and (not self._finished_file)):
        self._finish_file()
