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.
|
---|
In Section
Seekers of Perl Wisdom