from BeautifulSoup import BeautifulSoup import urllib2 import re url = urllib2.urlopen("http://www.sharejs.com") content = url.read() soup = BeautifulSoup(content) for a in soup.findAll('a',href=True): if re.findall('sharejs', a['href']): print "Found the URL:", a['href'] #//python/8421