Link Extractor in Python

D4rk357, my friend made a Link Extractor in python. A very useful tool to extratct links form website:

#!/usr/bin/python
 #A  small link extractor program .
import os,sys,urllib,re,httplib

if len(sys.argv) != 2:
print "\n|-----------------------------------------------------------------|"
print "| lastman100[@]gmail[dot]com |"
print "| 10/2010 Link Extractor v0.1 |"
print "| Visit : http://www.garage4hackers.com |"
print "|-----------------------------------------------------------------|\n"

ab=raw_input("enter URL to extract the link\n")
ht=re.compile("http://")
if ht.search(ab):
sa=urllib.urlopen(ab)
else:
sa=urllib.urlopen('http://'+ab)

st=sa.read()

link=re.compile('http\S\W+'+'\S+')

y =link.finditer(st)

for i in y:
print i.group()

Leave a comment