clean up code
This commit is contained in:
parent
d9949f13e4
commit
c5d93d626c
1 changed files with 5 additions and 6 deletions
11
owug.py
11
owug.py
|
@ -29,14 +29,13 @@ soup = BeautifulSoup(html, 'html5lib')
|
||||||
# hardcode favicon
|
# hardcode favicon
|
||||||
favicons = soup.find_all('link', rel='icon')
|
favicons = soup.find_all('link', rel='icon')
|
||||||
for favicon in favicons:
|
for favicon in favicons:
|
||||||
if 'icon' in favicon.attrs['rel']:
|
url = absolute_url(favicon.attrs['href'], domain_thing)
|
||||||
url = absolute_url(favicon.attrs['href'], domain_thing)
|
|
||||||
|
|
||||||
mime_type = requests.head(url).headers['Content-Type']
|
mime_type = requests.head(url).headers['Content-Type']
|
||||||
as_base64 = b64encode_as_string(requests.get(url).content)
|
as_base64 = b64encode_as_string(requests.get(url).content)
|
||||||
new_url = f'data:{mime_type};base64,{as_base64}'
|
new_url = f'data:{mime_type};base64,{as_base64}'
|
||||||
|
|
||||||
favicon.attrs['href'] = new_url
|
favicon.attrs['href'] = new_url
|
||||||
|
|
||||||
# hardcode images
|
# hardcode images
|
||||||
imgs = soup.find_all('img')
|
imgs = soup.find_all('img')
|
||||||
|
|
Loading…
Reference in a new issue