Get all the links from a website using Python

import urllib2 import re #connect 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
This code snippet written in Python gets all the links from any websites HTML code.

To find all the links, this example uses the urllib2 module together with the re.module

#url #links #link

#python

#cesarnog

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.