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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http request from cgi script

Status
Not open for further replies.

Perlwannabe

Technical User
Mar 7, 2006
57
IT
Hello,

How to require a web page trough a cgi script?

Thanks in advance for your reply

sincerely
 
please explain your question in more detail.

- Kevin, perl coder unexceptional!
 
Hi Kevin![smile]

I would create a simple cgi script that requires an url just like a browser. Could you help mewith the synthax?

Thanks


 
do you mean aquire instead of require?

- Kevin, perl coder unexceptional!
 
Look into LWP::Simple if all you need is to fetch a webpage




- Kevin, perl coder unexceptional!
 
If you mean something like:

Code:
[URL unfurl="true"]http://mydomain.com/script.cgi?http://another-site.com[/URL]

Code:
my $url = $ENV{QUERY_STRING};

$ENV{QUERY_STRING} would have everything after the ? mark.

If you meant this:

Code:
[URL unfurl="true"]http://mydomain.com/script.cgi/http://another-site.com[/URL]

Code:
my $url = $ENV{PATH_INFO};

Not all servers support PATH_INFO, but when you have a / after the CGI file name as in that example, the data after the slash (or maybe containing the first slash) is in $ENV{PATH_INFO}.

If you wanted your CGI to request another URL within itself, look into LWP::Simple.

Code:
use LWP::Simple;
my $html_code = get "[URL unfurl="true"]http://another-site.com/index.html";[/URL]

-------------
Kirsle.net | Kirsle's Programs and Projects
 
Thank you guys!

I'll try the various proposed solutions to see wich one fits best for my needs.

I'll let you know.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top