Fix for sites that have a base tag
This commit is contained in:
+5
-1
@@ -618,7 +618,11 @@ def process_html_document(html_content, original_url):
|
|||||||
base_url = urljoin(base_url, parsed_url.path.rsplit("/", 1)[0] + "/")
|
base_url = urljoin(base_url, parsed_url.path.rsplit("/", 1)[0] + "/")
|
||||||
|
|
||||||
base_tag = soup.find("base")
|
base_tag = soup.find("base")
|
||||||
if not base_tag:
|
if base_tag:
|
||||||
|
# Always overwrite — sites may have <base href="/"> which would resolve
|
||||||
|
# root-relative asset paths to the 13ft server instead of the original domain.
|
||||||
|
base_tag["href"] = base_url
|
||||||
|
else:
|
||||||
new_base_tag = soup.new_tag("base", href=base_url)
|
new_base_tag = soup.new_tag("base", href=base_url)
|
||||||
if soup.head:
|
if soup.head:
|
||||||
soup.head.insert(0, new_base_tag)
|
soup.head.insert(0, new_base_tag)
|
||||||
|
|||||||
Reference in New Issue
Block a user