Solved

Extracting records from an html page

Posted on 2004-04-16
3
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pattern matching in perl 2 116
Port 80 requests 16 111
Edit Odbc.ini using perl module 2 96
how to exit a  for loop inside a function with return value in bash 5 114
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

738 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