tessl install tessl/pypi-w3lib@2.3.0Library of web-related functions for HTML manipulation, HTTP processing, URL handling, and encoding detection
Agent Success
Agent success rate when using this tile
84%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.91x
Baseline
Agent success rate without this tile
92%
A utility module for cleaning and filtering query parameters in URLs based on configurable rules.
Build a function that removes specified query parameters from URLs to protect sensitive information before logging or sharing URLs.
sanitize_url("https://example.com?token=secret&id=123", ["token"]) returns "https://example.com?id=123" @testsanitize_url("https://example.com?token=abc&session=xyz&id=5", ["token", "session"]) returns "https://example.com?id=5" @testsanitize_url("https://example.com?id=123", ["token"]) returns "https://example.com?id=123" @testBuild a function that keeps only specified query parameters, removing all others. This is useful for creating clean URLs with only relevant parameters.
filter_url_params("https://example.com?id=123&name=test&extra=foo", ["id"]) returns "https://example.com?id=123" @testfilter_url_params("https://example.com?a=1&b=2&c=3&d=4", ["a", "c"]) returns "https://example.com?a=1&c=3" @testfilter_url_params("https://example.com?x=1&y=2", ["z"]) returns "https://example.com" @testBuild a function that removes duplicate query parameters, keeping only unique parameter names and their first occurrence.
remove_duplicate_params("https://example.com?id=1&id=2&id=3") returns "https://example.com?id=1" @testremove_duplicate_params("https://example.com?a=1&b=2&a=3&c=4") returns "https://example.com?a=1&b=2&c=4" @testBuild a function that strips fragment identifiers (the part after #) from URLs while preserving query parameters.
remove_fragment("https://example.com?id=123#section") returns "https://example.com?id=123" @testremove_fragment("https://example.com#section") returns "https://example.com" @test@generates
def sanitize_url(url: str, params_to_remove: list[str]) -> str:
"""
Remove specified query parameters from a URL.
Args:
url: The URL to process
params_to_remove: List of parameter names to remove
Returns:
URL with specified parameters removed
"""
pass
def filter_url_params(url: str, params_to_keep: list[str]) -> str:
"""
Keep only specified query parameters, removing all others.
Args:
url: The URL to process
params_to_keep: List of parameter names to keep
Returns:
URL with only the specified parameters
"""
pass
def remove_duplicate_params(url: str) -> str:
"""
Remove duplicate query parameters, keeping first occurrence.
Args:
url: The URL to process
Returns:
URL with duplicate parameters removed
"""
pass
def remove_fragment(url: str) -> str:
"""
Remove fragment identifier from URL while preserving query parameters.
Args:
url: The URL to process
Returns:
URL without fragment
"""
passProvides web-related utility functions for URL manipulation and query parameter handling.