This is a new module for python3. The urllib package serves as a namespace only. You might get error while using .parse
if you don't import requests
or parse
urllib
is a package that collects several modules for working with URLs:
urllib.request
for opening and reading URLsurllib.error
containing the exceptions raised by urllib.request
urllib.parse
for parsing URLsurllib.robotparser
for parsing robots.txt
filesurllib.parse
quote()
- url_encodeurllib.parse.quote(string, safe='/', encoding=None, errors=None)
Replace special characters in string using the %xx
escape. Letters, digits, and the characters '_.- ~'
are never quoted. By default, this function is intended for quoting the path section of a URL. The optional safe parameter specifies additional ASCII characters that should not be quoted - its default value is '/'.
Example: -
quote_plus()
- url_encodeurllib.parse.quote_plus(string, safe='', encoding=None, errors=None)
Like quote(), but also replace spaces with plus signs, as required for quoting HTML form values when building up a query string to go into a URL. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'.
Example: -
<aside>
💡 Similarly, urllib.parse.unquote(string, encoding='utf-8', errors='replace')
and urllib.parse.unquote_plus(string, encoding='utf-8', errors='replace')
</aside>