lint: Fix all E302 linting errors

This commit is contained in:
Drikus Roor
2023-04-12 23:05:14 +02:00
committed by Drikus Roor
parent 04dc0f7149
commit d1ea6cf002
20 changed files with 47 additions and 0 deletions

View File

@@ -21,12 +21,28 @@ def sanitize_url(url):
return urljoin(url, urlparse(url).path)
# Function to make a request with a specified timeout and handle exceptions
def make_request(url, timeout=10):
try:
response = requests.get(url, headers=cfg.user_agent_header, timeout=timeout)
response.raise_for_status()
return response
except requests.exceptions.RequestException as e:
return "Error: " + str(e)
# Define and check for local file address prefixes
def check_local_file_access(url):
local_prefixes = ['file:///', 'file://localhost', 'http://localhost', 'https://localhost']
return any(url.startswith(prefix) for prefix in local_prefixes)
def scrape_text(url):
"""Scrape text from a webpage"""
# Basic check if the URL is valid
if not url.startswith('http'):
return "Error: Invalid URL"
def get_response(url, headers=cfg.user_agent_header, timeout=10):
try:
# Restrict access to local files