mirror of
https://github.com/marty-oehme/scripts.git
synced 2025-12-10 22:12:45 +00:00
Version 0.2
This commit is contained in:
parent
031666520f
commit
8a2a34c114
5 changed files with 249 additions and 129 deletions
|
|
@ -61,9 +61,14 @@ class URL:
|
|||
try:
|
||||
html_text = urllib.request.urlopen(self.url).read().decode('utf-8') # TODO encodings other that utf-8, https fails on early Python 3 versions
|
||||
except (urllib.error.HTTPError, urllib.error.URLError, UnicodeDecodeError):
|
||||
return ''
|
||||
title = ''
|
||||
else:
|
||||
return re.search('<title.*?>(.+?)</title>', html_text, re.IGNORECASE | re.DOTALL).group(1)
|
||||
title = re.search('<title.*?>(.+?)</title>', html_text, re.IGNORECASE | re.DOTALL).group(1)
|
||||
|
||||
if title:
|
||||
return title
|
||||
else:
|
||||
return self.url.split('//')[-1].split('/')[0]
|
||||
|
||||
@property
|
||||
def md(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue