Explain the function which is used to retrieve the parts of URL in python

Urllib module is the URL handling module for python.
It is used to fetch URLs (Uniform Resource Locators).

It uses the urlopen function and is able to fetch URLs using a variety of different protocols.
Urllib is a package that collects several modules for working with URLs, such as:
1 urllib.request for opening and reading.
2 urllib.parse for parsing URLs
3 urllib.error for the exceptions raised
4 urllib.robotparser for parsing robot.txt files
Urllib.parse is the function which used to retrieve the parts of URL
urllib.parse This module helps to define functions to focuses on splitting a URL into small components

import urllib.parse
parse_url = urlparse('https://demo.com') 

ParseResult(scheme='https', netloc='www.demo.com', path='/python-langtons-ant/', params='', query='', fragment='')

To Learn more about Python, Click Here

Click here To Follow on pinterest

Leave a Comment

Your email address will not be published. Required fields are marked *