Gossamer Forum
Home : General : Perl Programming :

Need help making script

Quote Reply
Need help making script
I have recently set up to create a script which uses LWP:Simple to fetch the news at yahoo.
I have successfully gotten it to fetch the page and sort out all the unwanted html tags. But I what I want is when the users click on the headline I want the script to fetch the story as well. Here is the code I have so far.
Code:
#!/usr/bin/perl5

use LWP::Simple;

#retrieve the page which should be modified
my $news = get("http://dailynews.yahoo.com/headlines/ts/index.html");
$news =~ s/\n//g;

#everything above this will be cut off
$news =~ s/^.*Full Coverage<\/a>//is;

#everything below this will be cut off
$news =~ s/<hr><h2>Earlier Stories<\/h2>.*$//is;

# get rid of stupid stupid subheads
$news =~ s/<font.*?\/font>//sg;

$news =~ s/<b>\n//sg;
$news =~ s/<\/b>\n//sg;
$news =~ s/<b>//sg;
$news =~ s/<\/b>//sg;

# get rid of <br>'s and other unnecessary junk
$news =~ s/<\/font><\/center>//sg;
$news =~ s/ //sg;
$news =~ s/<p>//sg;
$news =~ s/<\/center>\n//sg;
$news =~ s/<\/font>\n//s;
$news =~ s/<p>\n//s;
$news =~ s/^\n//sg;
print "Content-type: text/html\n\n";

#print result
print "$news";
Quote Reply
Re: Need help making script In reply to
Sorry it looks like there is an error in there but it looks as though it will be ok it is the line
$news =~ s/ //sg;