from ddgs import DDGS def web_fetch(url: str, format: str = "text_markdown") -> str: """Fetch a URL and extract its content. Args: url: The URL to visit and extract content from format: Output format: "text_markdown", "text_plain", "text_rich", "text" (raw HTML), "content" (raw bytes). Returns: Extracted content from the page """ try: with DDGS() as ddgs: result = ddgs.extract(url, fmt=format) content = result.get("content", "") return content except Exception as e: return f"Error visiting URL: {str(e)}"