вот рабочий пример:
import urllib.parse as urlparse
from urllib.parse import parse_qs
def replace_params_with_x(url):
parsed = urlparse.urlparse(url)
params= parse_qs(parsed.query)
modified_params={key : ["x" * len (val) for val in values] for key, values in params.items()}
url_modified=url.split("?")[0]
# i have params
rplc = "&".join([ "%s=%s" % (key, val) for key, values in modified_params.items() for val in values ])
if rplc:
url_modified += "?" +rplc
return url_modified
# example on a single url (applicable to any url)
url = 'www.example.com/abc?file=my_file&url=my_url'
print(replace_params_with_x(url))
вывод: www.example.com/abc?&file=xxxxxxx&url=xxxxxx