1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 00:15:22 +01:00

Fix an error in _soup if parsed content doesn't have a <head>

This commit is contained in:
David Lynch 2025-03-06 22:31:23 -06:00
parent 5213ec2632
commit cfd073fb5c

View file

@ -207,7 +207,7 @@ class Site:
text = url text = url
fallback_base = '' fallback_base = ''
soup = BeautifulSoup(text, method) soup = BeautifulSoup(text, method)
return soup, soup.head.base and soup.head.base.get('href') or fallback_base return soup, (soup.head and soup.head.base) and soup.head.base.get('href') or fallback_base
def _form_in_soup(self, soup): def _form_in_soup(self, soup):
if soup.name == 'form': if soup.name == 'form':
@ -247,7 +247,7 @@ class Site:
return data, form.attrs.get('action'), form.attrs.get('method', 'get').lower() return data, form.attrs.get('action'), form.attrs.get('method', 'get').lower()
def _new_tag(self, *args, **kw): def _new_tag(self, *args, **kw):
soup, nobase = self._soup('') soup = BeautifulSoup("", self.options.get('parser'))
return soup.new_tag(*args, **kw) return soup.new_tag(*args, **kw)
def _join_url(self, *args, **kwargs): def _join_url(self, *args, **kwargs):