Adding most basic URL validation in scrape_text
parent
06f26cb29c
commit
da4a045bd6
|
@ -6,6 +6,10 @@ from llm_utils import create_chat_completion
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
def scrape_text(url):
|
def scrape_text(url):
|
||||||
|
# Most basic check if the URL is valid:
|
||||||
|
if not url.startswith('http'):
|
||||||
|
return "Error: Invalid URL"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, headers=cfg.user_agent_header)
|
response = requests.get(url, headers=cfg.user_agent_header)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
|
|
Loading…
Reference in New Issue