I started with Perl a few days ago and now reached a point I don't see how to get further. Thus, I'd like to have a text file created for each id (max. currently 30000) on www.securityfocus.com/bid. The information I need is in a table, this is why I use depth and count. So far I have coded the following:
#!C:\perl\bin\perl.exe -w # Purpose: Script for extracting data from tables and write it to a te +xt file # Version: 0.3 print "Content-type: text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); use strict; use HTML::TableExtract; my $table; # table of interest my $html_file = "http://www.securityfocus.com/bid"; # url of web site my $te; # table extract my $ts; # table search my $row; # row of table of interest my @securityfocus; # array for(1..30000) { my $table = $html_file."/".$_; $te = HTML::TableExtract->new( depth => 1, count => 0 ); $te->parse_file($table); } foreach $ts ($te->tables) { print "Table found at ", join(',', $ts->coords), ":\n"; foreach $row ($ts->rows) { print " ", join(',', @$row), "\n"; } } @securityfocus=("Bugtraq ID: \n","Class: \n","CVE: \n","Remote: \n","L +ocal: \n", "Published: \n","Updated: \n","Credit: \n","Vulnerable: \n","Not Vulne +rable: \n"); open(OUTPUTFILE,">bid.txt") or die "Can't open bid.txt $!"; print OUTPUTFILE @securityfocus; close(OUTPUTFILE) or die "Can't close bid.txt $!"; open(OUTPUTFILE,"bid.txt") or die "Can't open bid.txt $!"; while (<OUTPUTFILE>) { chomp; print " $_ \n"; } close(OUTPUTFILE) or die "Can't close bid.txt $!";
I appreciate your help - Tom

In reply to Extract table info and create txt file by TomBombadil

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.