def open_url(self, url, stale_after, parse_as_html = True, **kwargs):
_LOGGER.info('<STR_LIT>', url)<EOL>today = datetime.date.today()<EOL>threshold_date = today - datetime.timedelta(stale_after)<EOL>downloaded = False<EOL>with self._get_conn() as conn:<EOL><INDENT>rs = conn.execute('''<STR_LIT>'''<EOL>ert or replace <EOL>o cache<EOL>l, date, content)<EOL><DEDENT>ues<EOL><INDENT>?,?)<EOL>,<EOL>(<EOL><INDENT>str(url),<EOL>_date_to_sqlite_str(today),<EOL>sqlite3.Binary(to_store)<EOL>
Download or retrieve from cache.

url -- The URL to be downloaded, as a string.

stale_after -- A network request for the url will be performed if the
cached copy does not exist or if it exists but its age (in days) is
larger or equal to the stale_after value. A non-positive value will
force re-download.

parse_as_html -- Parse the resource downloaded as HTML. This uses the
lxml.html package to parse the resource leniently, thus it will not
fail even for reasonably invalid HTML. This argument also decides the
return type of this method; if True, then the return type is an
ElementTree.Element root object; if False, the content of the resource
is returned as a bytestring.

Exceptions raised:

BannedException -- If does_show_ban returns True.

HTTPCodeNotOKError -- If the returned HTTP status code 
                                          is not equal to 200.