AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Merge
BillSchumacher52bb22d8d1c7
diff --git a/autogpt/commands/web_requests.py b/autogpt/commands/web_requests.pyindex 230b1ff091..051cc710fc 100644--- a/autogpt/commands/web_requests.py+++ b/autogpt/commands/web_requests.py@@ -3,6 +3,7 @@ from typing import List, Tuple, Unionfrom urllib.parse import urljoin, urlparseimport requests+from requests.compat import urljoinfrom requests import Responsefrom bs4 import BeautifulSoup@@ -134,19 +135,20 @@ def scrape_text(url: str) -> str:return text-def extract_hyperlinks(soup: BeautifulSoup) -> List[Tuple[str, str]]:+def extract_hyperlinks(soup: BeautifulSoup, base_url: str) -> List[Tuple[str, str]]:"""Extract hyperlinks from a BeautifulSoup objectArgs:soup (BeautifulSoup): The BeautifulSoup object+ base_url (str): The base URLReturns:List[Tuple[str, str]]: The extracted hyperlinks"""- hyperlinks = []- for link in soup.find_all("a", href=True):- hyperlinks.append((link.text, link["href"]))- return hyperlinks+ return [+ (link.text, urljoin(base_url, link["href"]))+ for link in soup.find_all("a", href=True)+ ]def format_hyperlinks(hyperlinks: List[Tuple[str, str]]) -> List[str]:@@ -183,7 +185,7 @@ def scrape_links(url: str) -> Union[str, List[str]]:for script in soup(["script", "style"]):script.extract()- hyperlinks = extract_hyperlinks(soup)+ hyperlinks = extract_hyperlinks(soup, url)return format_hyperlinks(hyperlinks)