/ Published in: Python
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
import re,sgmllib,sys,urllib
class Parser(sgmllib.SGMLParser):
def start_a(self, attr):
regx = re.compile('[Hh][Tt][Tt][Pp].*\....$')
href = [v for a, v in attr if a == 'href']
try:
if regx.match(href[0]): print href[0]
except:
pass
if __name__ == '__main__':
try:
fd = urllib.urlopen(sys.argv[1])
parser = Parser()
parser.feed(fd.read())
parser.close()
fd.close()
except Exception, error:
print 'Errore: ' + str(error)
Comments
 Subscribe to comments
                    Subscribe to comments
                
                