Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP:: Simple problem - no HTML!

Status
Not open for further replies.

mpalmer12345

Programmer
Feb 16, 2004
59
US
I am trying to use the LWP:: Simple command. When I do the following, all I get is the simple webpage link returned to me, not the HTML code!

<form name="form3"
METHOD="POST" ACTION="/cgi-bin/Scrip01.cgi">
<p>ENTER THE URL OF WEBSITE PAGE:</p>
<input type="text" name="urlval" size="100">
<input type="submit" value="ENTER">


THIS GOES TO Scrip01.cgi

#!/usr/bin/perl
use LWP::Simple;
use CGI;
my $cgi = new CGI;
my $text = $cgi->param("urlval");
print "Content-type: text/html\n\n";
print "$text\n";

SO, WHEN USER INPUTS

HE GETS BACK, LITERALLY

What's weird is that this was working for me last week on the same server under a different name!
 
But shouldn't it print out the HTML code of the webpage instead of simply the link?

Here's the place where I am testing this.


The cgi file the button takes the user to is coded as follows:

#!/usr/bin/perl
use LWP::Simple;
use CGI;
my $cgi = new CGI;
my $text = $cgi->param("urlval");
print "Content-type: text/html\n\n";

print "$text\n";


All I get back when I run this is the link that the user inputs. That is not what I want! I want the HTML code of the link, and it's not coming through. WHY NOT?
 
See the usage for LWP::Simple

You're not using it at all in the code you provided. I believe you'd have to have something like:
Code:
#!/usr/bin/perl
use LWP::Simple;
use CGI;
my $cgi = new CGI;
my $url = $cgi->param("urlval");
my $text = get($url); #Get the content of the page for the link provided
print "$text\n";

And of course add in some error checking in case the link is bad.
 
Aha! I left off the all-important GET step!
Stupid me. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top