import urllib
import htmllib
import formatter
class DigiumPageParser(htmllib.HTMLParser):
def __init__(self):
htmllib.HTMLParser.__init__(self, formatter.NullFormatter(), 0)
self.enlace = False
def start_a(self, attributes):
if dict(attributes).get('class') == 'descriptiontext':
self.enlace = True
def end_a(self):
self.enlace = False
def handle_data(self, data):
if self.enlace:
print data
if __name__ == '__main__':
parser = DigiumPageParser()
archivo = urllib.urlopen('http://www.voipsupply.com/index.php?ref=voip-supply&manufacturers_id=13')
parser.feed(archivo.read())