Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Use LWP get no URL response

by Sathishkumar (Scribe)
on Oct 02, 2015 at 07:04 UTC ( #1143641=note: print w/replies, xml ) Need Help??

in reply to Use LWP get no URL response

Hi, I think you miss accept type in the code. here I attached correct code for your help.
use strict; use HTTP::Cookies; use LWP::UserAgent; my $ua = LWP::UserAgent->new(show_progress=>1); $ua->agent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/2010010 +1 Firefox/26.0"); $ua->timeout(30); $ua->cookie_jar({}); my $filename ="indiegogo"; my $cookie_file = $filename."_cookie.txt"; unlink($cookie_file); my $cookie = HTTP::Cookies->new(file=>$cookie_file,autosave=>1); $ua->cookie_jar($cookie); my $url = ' +K4PACTU&WT.z_header=search_go'; my $req = HTTP::Request->new(GET=>$url); $req->header("Accept"=>"text/html,application/xhtml+xml,application/xm +l;q=0.9,*/*;q=0.8"); $req->header("Content-Type"=>"application/x-www-form-urlencoded"); my $res = $ua->request($req); $cookie->extract_cookies($res); $cookie->save; $cookie->add_cookie_header($req); my $code = $res->code(); print $code,"\n"; if($code =~ m/50/is) { sleep 1000; goto REPEAT; } my $content = $res->content(); open sr,">digikey.html"; print sr $content; close sr;
Thanks, Sathish

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1143641]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2018-07-21 08:15 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (445 votes). Check out past polls.