Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-08-08 04:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found