Library of web-related functions for HTML manipulation, HTTP processing, URL handling, and encoding detection
84
Build a URL parameter management utility that can update tracking and configuration parameters in URLs.
You're building a web crawler that needs to add tracking identifiers and modify configuration parameters in URLs before making requests. The URLs come from various sources and may or may not already contain query parameters.
Implement a function update_url_parameters that takes a URL and updates it with new parameter values:
The function should accept:
The function should:
session_id) if it doesn't existlang) if it doesn't existReturn the modified URL as a string
Create your implementation in url_manager.py.
Provides web-related utility functions for URL manipulation.
Should add parameters to URL without query string @test
"https://example.com/page" with session_id "abc123" and lang "en""https://example.com/page?session_id=abc123&lang=en"Should replace existing parameters @test
"https://example.com/search?q=test&session_id=old123&lang=fr" with session_id "new456" and lang "es""https://example.com/search?q=test&session_id=new456&lang=es"Should handle mix of new and existing parameters @test
"https://api.example.com/data?format=json&session_id=xyz" with session_id "updated789" and lang "de""https://api.example.com/data?format=json&session_id=updated789&lang=de"Install with Tessl CLI
npx tessl i tessl/pypi-w3libevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10