Extracting Data from Table
Posted: Fri Nov 18, 2005 1:12 am
I've got a few ADSL accounts that I want to keep track of easily. My ISP has a secure site where one can look up stats for each account for the month. I've made a script that logs into the site and retrieves the page with the stats and then cuts off the unnecessary bits before and after the stats (e.g. menu bar, disclaimer, etc.). It does this for as many accounts as I put into the script and then displays a summary of each account by displaying the table that has been extracted from the page.
I would like to extract the values out of that table and display them in my own way (or even save them to a db) but I have not worked with regex before. Could someone give me either a piece of code that could extract what I need or some good pointers please?
Here's the html code that's left after I've stripped the unnecessary bits (and is currently what just gets pasted into my summary page):
I need the Download, Upload and Combined values - I'm also guessing I'll need to strip the spaces from the values so it's treated as a number and not as a string.
I would like to extract the values out of that table and display them in my own way (or even save them to a db) but I have not worked with regex before. Could someone give me either a piece of code that could extract what I need or some good pointers please?
Here's the html code that's left after I've stripped the unnecessary bits (and is currently what just gets pasted into my summary page):
Code: Select all
<center><h3>Cumulative Totals for November 2005</h3></center>
<table cellspacing="1"><th>Sessions</th><th>Online Time (Seconds)</th><th>Upload (Bytes)</th><th>Download (Bytes)</th><th>Combined (Bytes)</th>
<tr><td>46</td><td>2934200</td><td>1 015 740 629</td><td>5 538 484 386</td><td>6 554 225 015</td></tr></table>