Created
November 17, 2019 06:23
-
-
Save CITGuru/49f32bf447b4474329a9e3c846ad7b2e to your computer and use it in GitHub Desktop.
Get all links from a website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import re | |
url = raw_input("Enter a URL: ") | |
#connecting to a URL | |
website = urllib2.urlopen(url) | |
#read html code | |
html = website.read() | |
#use re.findall to get all the links | |
links = re.findall('"((http|ftp)s?://.*?)"', html) | |
print(links) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment