Release 2025-05-19

This commit is contained in:
pluja
2025-05-19 10:23:36 +00:00
parent 2657f936bc
commit 565e9a0ad1
267 changed files with 49417 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
"""
HTTP utilities for the pyworker package.
"""
from typing import Optional
import requests
from pyworker.utils.app_logging import setup_logging
logger = setup_logging(__name__)
def fetch_url(url: str, timeout: int = 30) -> Optional[str]:
"""
Fetch content from a URL.
Args:
url: The URL to fetch.
timeout: The timeout in seconds.
Returns:
The text content of the response, or None if the request failed.
"""
try:
response = requests.get(url, timeout=timeout)
response.raise_for_status()
return response.text
except requests.RequestException as e:
logger.error(f"Error fetching URL {url}: {e}")
return None