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

trying to get content from web and save to file using LWP::USERAGENT

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
a while back i used this code to pull the contents from a web page and then save to a file. worked fine...

Code:
$ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$response = $ua->get('[URL unfurl="true"]http://xyzpage.net/i.pl?a=home');[/URL]
 if ($response->is_success) {$testresponse='good';}
 else {$testresponse='bad';}

it works fine if i'm trying to call up a different website, but if i run this code from my script and the script is from xyzpage.net, it produces a bad response.

basically, i'm trying to run this from a script, and it pulls a file that is also on the same directory.

if that makes any sense.

any ideas?

- g
 
try:

print $response->code( );

and see what the actual response is from the server.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
i got it. that's a regular error, a server error.

thanks for pointing me in the right direction.

it was working, but the code was on the script it was calling, and that was the error.

appreciated!

- g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top