url_utils
autogen.agents.experimental.document_agent.url_utils.URLAnalyzer
URLAnalyzer
A class that analyzes URLs to determine if they point to web pages or files.
Initialize the URLAnalyzer with a URL.
Name | Description |
---|---|
url | Type: str |
Class Attributes
FormatToMimeType
MimeTypeToFormat
format_type
mime_type
mime_types
Static Methods
get_supported_extensions
Return a list of supported file extensions.
get_supported_formats
Return a list of supported file formats.
get_supported_mime_types
Return a list of all supported MIME types.
Instance Methods
analyze
Analyze the URL to determine if it points to a web page or a file.
Name | Description |
---|---|
test_url | Whether to test the URL by making a request Type: bool Default: False |
follow_redirects | Whether to follow redirects when testing the URL Type: bool Default: True |
prioritize_extension | Whether to prioritize file extension over MIME type Type: bool Default: True |
Type | Description |
---|---|
dict[str, typing.Any] | dict: A dictionary containing the analysis results |
follow_redirects
Follow redirects for the URL without analyzing content types.
Returns:
Tuple[str, list[str]]: The final URL and the redirect chain
Type | Description |
---|---|
Tuple[str, list[str]] | Tuple[str, list[str]]: The final URL and the redirect chain |
get_redirect_info
Get information about redirects that occurred during the last request.
Returns:
dict: Information about redirects
Type | Description |
---|---|
dict[str, typing.Any] | dict: Information about redirects |
get_result
Get the last analysis result, or None if the URL hasn’t been analyzed yet.
Returns:
Optional[dict]: The analysis result or None
Type | Description |
---|---|
dict[str, typing.Any] | None | Optional[dict]: The analysis result or None |