Gossamer Forum
Home : Products : Links 2.0 : Discussions :

News headline grabber -- help needed!

Quote Reply
News headline grabber -- help needed!
Guys, I recently downloaded this "News Grabber" to which you can grab news from different outlets. Well I am trying to grab news the Detroit Free Press Lions page. Below is the script, can anyone tell me why the SSI call isn't working (it returns nothing)

------START CODE_-------

use English;
use CGI;
use integer;
require LWP::UserAgent;

#####################
# #
# Parse Form Inputs #
# #
#####################

$q = new CGI;
#print $q->header;
$mytest =$q->param(mytest);

#####################
$ssi = "no";
$ua = new LWP::UserAgent;
$the_cgi = CGI->new;
$domain = "freep.com/sports/lions";
#$domain = $ENV{'QUERY_STRING'}; # ex. "script.cgi?yahoo.com";
$begin = "http://";
$data = $begin . $domain;
$breakupa = "<a href="/sports/lions/"; # If this string is in a line, that line will be printed.
$breakupb = "<100jiggawatts>"; # If this string is in a line, that line will be printed.
$breakupc = "<100jiggawatts>"; # If this string is in a line, that line will be printed.
$replacea = "";
$replaceb = "http://www.freep.com";
$numheads = "3"; # Number of headlines you want to be printed Times Three!
$footer = "News Results by <a href=\"http://www.nflbeat.net\">NFLBeat.net</a>";
$lookup = new HTTP::Request 'GET', "$data";
$response = $ua->request($lookup);
@lines = split (/\n/, $response->content);

if ($ssi eq "no")
{
print "Content-type: text/html\n\n";
}

print $mytest;

$i = 0;
foreach $line (@lines)
{
if ($line =~ /$breakupa/ && $i < $numheads)
{
$line =~ s/$replacea/$replaceb/;
print $line;
$i += 1;
}
elsif ($line =~ /$breakupb/ && $i < $numheads)
{
print $line;
$i += 1;
}
elsif ($line =~ /$breakupc/ && $i < $numheads)
{
print $line;
$i += 1;
}
}
print $footer;
exit;

-----------END CODE---------

Quote Reply
Re: News headline grabber -- help needed! In reply to
I'm not familiar with this script, but if you're using SSI shouldn't the line

$ssi = "no";

be changed?

The other line you would need to check is

$domain = "freep.com/sports/lions";

as that is where it is trying to grab the news from as far as I can see. I would imagine that it needs to be more specific than just a directory.


Quote Reply
Re: News headline grabber -- help needed! In reply to
Hello boss,
This is not the forum for cgi problems. This is only Links discussion forum.
Hope i m right
Regs
JackofNone