Gossamer Forum
Home : General : Perl Programming :

Need Help pulling a web document

Quote Reply
Need Help pulling a web document
All,

I am having a problem with this small script. The program is supposed to go get a web page and strip off the headers and print the page to the browser. I runs perfectly from the command prompt. It prints the text to the screen without a problem. However when I call this as a CGI it only prduces the html tags and doesn't print the value of the $page variable to the browser. What would cause this? I am having the same problem with the altavista.cgi script.

Thanks,

Jim
jim@avera.net

#!/usr/bin/perl

use LWP::Simple;

#retrieve the page
my $page = get("http://headlines.isyndicate.com/rcscript/?user=7azhsswa");

$page =~ s/\n//g;

#dump the HEAD-part
$page =~ s/^.*<\/head>//is;

#dump the last tags
$page =~ s/<\/body>.*$//is;

print "Content-type: text/html\n\n";

print <<"html_here";

<html>
<head>
<title> Todays Daily News Headlines </title>
</head>
<body>
$page
</body>
</html>

html_here


Quote Reply
Re: Need Help pulling a web document In reply to
All,

FYI. I tried the code below as Alex suggested and it worked fine. I am not sure what is wrong. I know I am on a Linux/Apache server if that makes a difference.

THanks,

Jim
jim@avera.net

perl
use LWP::Simple;
print get ("http://www.yahoo.com");
print "Done\n";
<ctrl>-D