Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738"""Webpage fetch tool using Jina AI reader."""from typing import Optionalfrom pydantic import BaseModel, Field
class WebpageArgs(BaseModel): url: str = Field( ..., description="The URL of the webpage to fetch and convert to markdown/text format" )
def fetch_webpage(url: str) -> str: """ Fetch a webpage and convert it to markdown/text format using Jina AI reader. Args: url: The URL of the webpage to fetch and convert Returns: String containing the webpage content in markdown/text format """ import requests try: # Construct the Jina AI reader URL jina_url = f"https://r.jina.ai/{url}" # Make the request to Jina AI response = requests.get(jina_url, timeout=30) response.raise_for_status() return response.text except requests.exceptions.RequestException as e: raise Exception(f"Error fetching webpage: {str(e)}") except Exception as e: raise Exception(f"Unexpected error: {str(e)}")