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

LWP:UserAgent is mondo cool! Thanks Guys!

Status
Not open for further replies.

kempis555

Programmer
Joined
Jan 2, 2001
Messages
77
Reading a different thread here tipped me off to PERL's ability to easilty read the contents out of any web site!

This was a neato fix for my local problem of having some servers in front of the firewall and some behind, and only the HTTP port is available on any of them. (Yeah, the network administrators here are long-eared galoots.)

Anyhoot the idea would be cool for anyone who wants his/her perl to get something from the web:

#this example is accessing a cgi
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
# Create a request
my $req = new HTTP::Request GET => ' $req->content_type('application/x- $req->content('match= # Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
$the_goods = $res->content;
else{
print "Couldn't connect to website.";
}
 
I agree, LWP UserAgent is a VERY useful tool! I've even used it to have one of my cgi programs call a cgi program on another server! My program used LWP UserAgent to set up a form post to the other server cgi program, and that program simply returned a basic "page" that I parsed to find out the results. It saved me a LOT of hassle to be able to do that.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top