Ctrl + K
DocumentationLog inGet started

tessl/pypi-w3lib

tessl install tessl/pypi-w3lib@2.3.0

Library 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%

task.mdevals/scenario-7/

URL Parameter Sanitizer

A utility module for cleaning and filtering query parameters in URLs based on configurable rules.

Capabilities

Removes sensitive parameters

Build a function that removes specified query parameters from URLs to protect sensitive information before logging or sharing URLs.

  • Removes single parameter: sanitize_url("https://example.com?token=secret&id=123", ["token"]) returns "https://example.com?id=123" @test
  • Removes multiple parameters: sanitize_url("https://example.com?token=abc&session=xyz&id=5", ["token", "session"]) returns "https://example.com?id=5" @test
  • Handles missing parameters gracefully: sanitize_url("https://example.com?id=123", ["token"]) returns "https://example.com?id=123" @test

Preserves allowlisted parameters

Build a function that keeps only specified query parameters, removing all others. This is useful for creating clean URLs with only relevant parameters.

  • Keeps single parameter: filter_url_params("https://example.com?id=123&name=test&extra=foo", ["id"]) returns "https://example.com?id=123" @test
  • Keeps multiple parameters: filter_url_params("https://example.com?a=1&b=2&c=3&d=4", ["a", "c"]) returns "https://example.com?a=1&c=3" @test
  • Returns URL without query string if no parameters match: filter_url_params("https://example.com?x=1&y=2", ["z"]) returns "https://example.com" @test

Removes duplicate parameters

Build a function that removes duplicate query parameters, keeping only unique parameter names and their first occurrence.

  • Removes duplicate parameters: remove_duplicate_params("https://example.com?id=1&id=2&id=3") returns "https://example.com?id=1" @test
  • Handles mixed duplicates: remove_duplicate_params("https://example.com?a=1&b=2&a=3&c=4") returns "https://example.com?a=1&b=2&c=4" @test

Removes URL fragments

Build a function that strips fragment identifiers (the part after #) from URLs while preserving query parameters.

  • Removes fragment from URL with query: remove_fragment("https://example.com?id=123#section") returns "https://example.com?id=123" @test
  • Handles URL with fragment but no query: remove_fragment("https://example.com#section") returns "https://example.com" @test

Implementation

@generates

API

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
    """
    pass

Dependencies { .dependencies }

w3lib { .dependency }

Provides web-related utility functions for URL manipulation and query parameter handling.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/w3lib@2.3.x
tile.json