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

Re: Link Extraction when grabbing web page with USER/PASS

by zakb (Pilgrim)
on Mar 04, 2003 at 09:08 UTC ( #240275=note: print w/replies, xml ) Need Help??


in reply to Link Extraction when grabbing web page with USER/PASS

To get your idea working, you need to look at these lines of code:

# (1) your working example $res = $ua->request(HTTP::Request->new(GET => $url), sub {$p->parse($_[0])}); # compared with (2) $res = $ua->request($req)->as_string, sub {$p->parse($_[0])};

Looking carefully at the bracketing in the second line, it appears it should be more like:

$res = $ua->request($req, sub {$p->parse($_[0])});

Your version was not passing the callback to call LinkExtor to the UserAgent request method. The call signature for the request method in the form you want it is:

$response = $ua->request($request, \&callback);

where $request is a HTTP::Request object and &callback is a sub or whatever.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://240275]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2020-11-27 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?