'Encoded string with percent signs in it [duplicate]

In my scraping project I encountered a data point containing a string in the following form

string = "d%61b%69a%5f%62%65%79@yaho%6f.fr"
target_string = [email protected]

What encoding change should I do to wrongly encoded strings? How can I scrape these broken strings correctly?

Thank you



Solution 1:[1]

you need urllib unquote

>>> from urllib.parse import unquote
>>> unquote("d%61b%69a%5f%62%65%79@yaho%6f.fr")
'[email protected]'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ti7