mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-19 15:04:26 +01:00
removed un necessary changes
This commit is contained in:
@@ -5,17 +5,21 @@ from llm_utils import create_chat_completion
|
||||
|
||||
cfg = Config()
|
||||
|
||||
def get_website_content(url):
|
||||
response = requests.get(url, headers=cfg.user_agent_header)
|
||||
def scrape_text(url):
|
||||
# Most basic check if the URL is valid:
|
||||
if not url.startswith('http'):
|
||||
return "Error: Invalid URL"
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=cfg.user_agent_header)
|
||||
except requests.exceptions.RequestException as e:
|
||||
return "Error: " + str(e)
|
||||
|
||||
# Check if the response contains an HTTP error
|
||||
if response.status_code >= 400:
|
||||
return "Error: HTTP " + str(response.status_code) + " error"
|
||||
return response
|
||||
|
||||
|
||||
|
||||
def scrape_text(website_content):
|
||||
soup = BeautifulSoup(website_content.text, "html.parser")
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
for script in soup(["script", "style"]):
|
||||
script.extract()
|
||||
@@ -42,8 +46,14 @@ def format_hyperlinks(hyperlinks):
|
||||
return formatted_links
|
||||
|
||||
|
||||
def scrape_links(website_content):
|
||||
soup = BeautifulSoup(website_content.text, "html.parser")
|
||||
def scrape_links(url):
|
||||
response = requests.get(url, headers=cfg.user_agent_header)
|
||||
|
||||
# Check if the response contains an HTTP error
|
||||
if response.status_code >= 400:
|
||||
return "error"
|
||||
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
for script in soup(["script", "style"]):
|
||||
script.extract()
|
||||
|
||||
Reference in New Issue
Block a user