Finding all links from a webpage in Python

Python Script to find all links from a webpage

Source code :

import urllib.request
import re

#Provide the url of the webpage
url = ""

#Send a request
website = urllib.request.urlopen(url)

#Read the content
html =

#Convert it to String
html = str(html)

#Finding all the links
links = re.findall('"((http)s?://.*?)"', html)


Notes :

In this script, we have used the regular expression module to get all links from a webpage. In order to fetch the contents of the webpage we have used the urllib module.

Output :


Comments :