The parse
function in urllib.parse
can be used to encode url components. But its behavior is different from the standard javascript encoder.
In python
>>> import urllib
>>> urllib.parse.quote('(a+b)')
... '%28a%2Bb%29'
in Javascript
>>> encodeURIComponent('(a+b)')
... "(a%2Bb)"
Why is the python function more "strict" when encoding the url component?
If I understood it right, brackets are not reserved characters in urls. So I don't understand why they are escaped in the urllib parse function.