""" HTTP client module for making web requests. """ import logging import requests from bs4 import BeautifulSoup # Default headers to mimic a browser DEFAULT_HEADERS = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' } REQUEST_TIMEOUT = 20 def make_request(url: str) -> BeautifulSoup | None: """ Fetch a URL and return a BeautifulSoup object. Args: url: The URL to fetch Returns: BeautifulSoup object if successful, None otherwise """ try: response = requests.get(url, headers=DEFAULT_HEADERS, timeout=REQUEST_TIMEOUT) response.raise_for_status() return BeautifulSoup(response.content, 'html.parser') except requests.exceptions.RequestException as e: logging.error(f"Error fetching {url}: {e}") return None