Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extracting records from an html page

Posted on 2004-04-16
3
Medium Priority
?
152 Views
Last Modified: 2010-03-04
Hi all,
This is my very first post. I have a network appliance that sends me daily reports in html format. The goal is to input this daily data in an xl spreadsheet.

The format looks like this.

Daily Incoming Report : 01/01/2003
   Totals and Averages:
   Total Message Count                    87140
   Total Message Count (Encrypted/Signed) 10
   Total Messages (with SSL)              1498
   Total Messages (without SSL)           85642
   Total Message Volume (MB)              1441.18
   Average Messages per Hour              3630.83
   Average Volume per Hour (MB)           60.05


So far I have discovered two choices.
1, use lynx -dump html_file.html > text_file.txt which strips all the html tags, I then use sed to pull the lines I am interested in.
The dilema is to imprt those lines and files into xl.

2, I looked here and found this, but am not sure how to use it.
http://search.cpan.org/~msisk/HTML-TableExtract-1.08/lib/HTML/TableExtract.pm


Any help will be greatly appreciated.
Thanks

Noob
0
Comment
Question by:perlnoob
3 Comments
 
LVL 3

Accepted Solution

by:
PerlKing earned 200 total points
ID: 10847941
If my understanding is correct, you know how to extract the data from the HTML tables (using either of the above mentioned approaches) but you don't know how to create an xl sheet.

I can think of two alternatives:
1. If your requirement is simple and you need just a single-sheet xl page, then all you need to do is to print the data in comma seperated format (csv). For example, in the documentation link of TableExtract.pm that you mentioned, you can see the following spippet of code in the Snopsys section:

 # Examine all matching tables
 foreach $ts ($te->table_states) {
   print "Table (", join(',', $ts->coords), "):\n";
   foreach $row ($ts->rows) {
      print join(',', @$row), "\n";
   }
 }

This code prints the extracted data in a csv format. Just make this write into a file instead and name the file "something.csv". xl will be able to open this file for you.

2. If you need a more sophisticated xl sheet to be created you, could use this module
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-0.42/WriteExcel.pm

Hope that helped
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question