SPUG: Talk for tonight
Jeremy Devenport
jeremy at weezel.com
Wed Dec 19 00:16:07 CST 2001
I thought I remembered a way to get the URL of the initial request even
after redirects. Here's some code (based on the LWP::Parallel perldoc
page) that will let you get at the pre-redirection url. Hope this helps.
#!/usr/bin/perl -w
use strict;
use LWP::Parallel::UserAgent;
use HTTP::Request;
my $ua = new LWP::Parallel::UserAgent;
for my $url (@ARGV) {
$ua->register(new HTTP::Request('GET' => $url));
}
my $entries = $ua->wait();
foreach (keys %$entries) {
my $res = $entries->{$_}->response;
# start with the initial response set to the final response
my $init_res = $res;
# follow the "previous" chain back as far as possible
$init_res = $init_res->previous while $init_res->previous;
# are these different objects?
if ($init_res != $res) {
printf "redirected from %s to %s\n", $init_res->request->url,
$res->request->url;
}
# do stuff with the $res object
# $init_res->request->url is the pre-redirection location,
# $res->request->url is the final location
}
Jeremy
-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org] On Behalf
Of Geoffrey Grosenbach
Sent: Tuesday, December 18, 2001 12:59 PM
To: spug-list at pm.org
Subject: SPUG: Talk for tonight
Hey, everyone--
I'm a newcomer to the group, but am also foolhardy enough to offer to
give a lightning talk tonight on how I modified Ed Hill's Webpluck
program
(mentioned in TPJ a few years ago) with the LWP::Parallel module from
the CPAN. I was able to get it to run 3x faster (but not without a few
roadblocks, the solutions to which I'll be glad to share).
So, I hope you'll show up tonight and hear about it!
Geoff Grosenbach
http://www.GeoffreyGrosenbach.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your
Email-address For daily traffic, use spug-list for LIST ; for weekly,
spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list