You might find that there are better ways to get the data you want than parsing the HTML generated by MRTG (e.g., such as using SNMP directly). However, this might help if really need to parse the HTML:
If you are willing to use Python then a the BeautifulSoup library will help you. You will still have to write some code but BeautifulSoup is pretty flexible.
Here is a crude example that dumps all HTML tables in a page to CSV:
page = urllib2.urlopen(sys.argv).read()
soup = BeautifulSoup.BeautifulSoup(page)
csvout = csv.writer(sys.stdout)
for table in soup.findAll('table'):
print '# Table'
print '# Fields: ' + ','.join([tr.text for tr in table.findAll('th')])
for row in table.findAll('tr'):
csvout.writerow([tr.text for tr in row.findAll('td')])
Assuming that you have Python installed as well as BeautifulSoup (
pip install BeautifulSoup or
easy_install BeautifulSoup) and assuming that you have saved the above code as
htmltable2csv.py you can display all the tables on a page like this:
python htmltable2csv.py http://www.w3schools.com/tags/tag_table.asp