#coding:gbk import HTMLParser import urllib import sys class parseLinks(HTMLParser.HTMLParser): def handle_starttag(self,tag,attrs): if tag=="a": for name,value in attrs: if name=='href': print value print self.get_starttag_text() IParser=parseLinks() IParser.feed(urllib.urlopen("http://automationtesting.xxxxx/").read()) IParser.close()
找到a標籤和href標籤python