Adding most basic URL validation in scrape_text

pull/625/head
Itamar Friedman 2023-04-10 08:26:46 +03:00
parent 06f26cb29c
commit da4a045bd6
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,10 @@ from llm_utils import create_chat_completion
cfg = Config()
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: