Solved

Extracting records from an html page

Posted on 2004-04-16
3
144 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 50 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now