CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
html get

 



PGScooter
stranger

Mar 25, 2001, 2:02 PM

Post #1 of 1 (189 views)
html get Can't Post

I'm not sure whether this belongs in the intermediate or beginner so please move it if it belongs elsewhere.
I can not fiugre out what I am doing wrong with the script! It retrieves the html code great and posts it with just one slight problem, the last word on each definition is always missing. The code first gets the html code... then extracts the lines that begin with "<Li> and then removes the tags, and then writes each definition to OUTPUT...
Any ideas? thankyou
pl file:

use LWP::Simple;
use HTML::Parse;
use HTML::FormatText;

$VocabList='<vocablist.txt';

open(INFILE,$VocabList)
or die "The txt file could not be found.\n";

$List=<INFILE>;

@words=split(/ /,$List);

open(OUTPUT,'>output.txt');



foreach $i(@words)
{
$definition=get("http://www.dictionary.com/cgi-bin/dict.pl?term=$i");
print OUTPUT "\n\n$i\n\n\t";
@lines = split(/\n/,$definition);
foreach $line (@lines)
{
if($line=~/^<LI>/)
{
$stripped = HTML::FormatText->new->format(parse_html($line));
print OUTPUT "$stripped\n\t";
}
}
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives