scrapling / src /scrapers /tor /utils.py
GraziePrego's picture
Upload original Scraper_hub repo as-is
eb37804 verified
raw
history blame contribute delete
465 Bytes
"""Shared utilities for Tor-related scraping."""
from urllib.parse import urlparse
def is_onion_url(url: str) -> bool:
"""
Check if the given URL is an onion service.
Args:
url: The URL to check
Returns:
True if the URL is a .onion address, False otherwise
"""
try:
parsed = urlparse(url)
return parsed.hostname.endswith('.onion') if parsed.hostname else False
except Exception:
return False