tooluniverse.url_tool module¶
- class tooluniverse.url_tool.BaseTool(tool_config)[source][source]¶
Bases:
object
- classmethod get_default_config_file()[source][source]¶
Get the path to the default configuration file for this tool type.
This method uses a robust path resolution strategy that works across different installation scenarios:
Installed packages: Uses importlib.resources for proper package resource access
Development mode: Falls back to file-based path resolution
Legacy Python: Handles importlib.resources and importlib_resources
Override this method in subclasses to specify a custom defaults file.
- Returns:
Path or resource object pointing to the defaults file
- tooluniverse.url_tool.unescape(s)[source][source]¶
Convert all named and numeric character references (e.g. >, >, &x3e;) in the string s to the corresponding unicode characters. This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and the list of HTML 5 named character references defined in html.entities.html5.
- tooluniverse.url_tool.register_tool(tool_type_name=None, config=None)[source][source]¶
Decorator to automatically register tool classes and their configs.
- Usage:
@register_tool(‘CustomToolName’, config={…}) class MyTool:
pass
- class tooluniverse.url_tool.URLHTMLTagTool(tool_config)[source][source]¶
Bases:
BaseTool
Fetches a webpage and extracts the content of a specified HTML tag. Expects: {“url”: “https://…”} The tag to extract is specified in the tool’s configuration. The tag to extract is specified in the tool’s configuration. Optional: {“timeout”: <seconds>} (default 20) Returns: {“content”: “<extracted content>”} or {“error”: “…”}