Retrieving Text from HTML Documents : Parse HTML : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » Parse HTML »

 

Retrieving Text from HTML Documents


import HTMLParser
import urllib

urlText = []

class parseText(HTMLParser.HTMLParser):
    def handle_data(self, data):
        if data != 'n':
            urlText.append(data)


lParser = parseText()

lParser.feed(urllib.urlopen("http://www.python.org/index.html").read())
lParser.close()
for item in urlText:
    print item



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» Parse HTML