# How to parse data from HTML

**URL:** <https://forum.inductiveautomation.com/t/how-to-parse-data-from-html/7072>\
**Category:** General Discussion\
**Created:** [August 18, 2013, 5:19am UTC](https://forum.inductiveautomation.com/t/how-to-parse-data-from-html/7072 "2013-08-18T05:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmadill](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@rmadill](https://forum.inductiveautomation.com/u/rmadill)\
**Post date:** [August 18, 2013, 5:19am UTC](https://forum.inductiveautomation.com/t/how-to-parse-data-from-html/7072/1 "2013-08-18T05:19:32Z")

</div>

Looking for a solution to extract data from HTML ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

Thanks

Rob

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 18, 2013, 3:38pm UTC](https://forum.inductiveautomation.com/t/how-to-parse-data-from-html/7072/2 "2013-08-18T15:38:49Z")

</div>

You can use Python’s built-in HTMLParser module, but if you’re not handy with programming it probably won’t be an easy task. See [here](http://docs.python.org/release/2.5.2/lib/module-HTMLParser.html) for documentation on how it works.

The following is a quick example that you can put into the actionPerformed of a button to see it in action…

```auto
from HTMLParser import HTMLParser

class MyHTMLParser(HTMLParser):

    def handle_starttag(self, tag, attrs):
        print "Encountered the beginning of a %s tag" % tag

    def handle_endtag(self, tag):
        print "Encountered the end of a %s tag" % tag
        

parser = MyHTMLParser()

parser.feed("<html><body><div>hi</div></body></html>")
```

The following will be printed to console:

```auto
Encountered the beginning of a html tag
Encountered the beginning of a body tag
Encountered the beginning of a div tag
Encountered the end of a div tag
Encountered the end of a body tag
Encountered the end of a html tag
```
