Add assets for the Automated Amazon Price Tracking article

This commit is contained in:
BexTuychiev
2024-12-06 23:05:18 +05:00
parent 4d287bb77f
commit 742c3df67e
21 changed files with 3404 additions and 0 deletions
@@ -0,0 +1,28 @@
from urllib.parse import urlparse
import re
def is_valid_url(url: str) -> bool:
try:
# Parse the URL
result = urlparse(url)
# Check if scheme and netloc are present
if not all([result.scheme, result.netloc]):
return False
# Check if scheme is http or https
if result.scheme not in ["http", "https"]:
return False
# Basic regex pattern for domain validation
domain_pattern = (
r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z]{2,})+$"
)
if not re.match(domain_pattern, result.netloc):
return False
return True
except Exception:
return False