|
Prev: file convesrions
Next: longest common substring
From: Nospam on 31 Oct 2006 10:24 I am looking at lwp::useragent to follow a redirect, so far I have : #! Perl/bin/perl use strict; use warnings; use Data::Dumper; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(100); $ua->max_redirect(100); #my $url= 'http://epa.gov/npdes/'; my $url= 'http://www.google.com'; my $response = $ua->get($url); print "$url\n"; printing http://epa.gov/npdes/ should redirect to http://cfpub.epa.gov/npdes/ but nothing happens.
From: yankeeinexile on 31 Oct 2006 10:34 "Nospam" <nospam(a)home.com> writes: > I am looking at lwp::useragent to follow a redirect, so far I have : > > #! Perl/bin/perl > use strict; > use warnings; > > use Data::Dumper; > use LWP::UserAgent; > > my $ua = LWP::UserAgent->new; > $ua->timeout(100); > $ua->max_redirect(100); > > > > #my $url= 'http://epa.gov/npdes/'; > > my $url= 'http://www.google.com'; > > my $response = $ua->get($url); > > > > print "$url\n"; > > > printing http://epa.gov/npdes/ should redirect to > http://cfpub.epa.gov/npdes/ but nothing happens. It isn't clear from reading the documentation, but LWP::UserAgent only handles redirection at the HTTP layer, not the HTML-layer with http-equiv. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - lawrenabae(a)abaluon.abaom s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is required is to sort them into the correct order.
From: Nospam on 31 Oct 2006 13:36 <yankeeinexile(a)gmail.com> wrote in message news:87y7qwo5wd.fsf(a)gmail.com... > "Nospam" <nospam(a)home.com> writes: > > I am looking at lwp::useragent to follow a redirect, so far I have : > > > > #! Perl/bin/perl > > use strict; > > use warnings; > > > > use Data::Dumper; > > use LWP::UserAgent; > > > > my $ua = LWP::UserAgent->new; > > $ua->timeout(100); > > $ua->max_redirect(100); > > > > > > > > #my $url= 'http://epa.gov/npdes/'; > > > > my $url= 'http://www.google.com'; > > > > my $response = $ua->get($url); > > > > > > > > print "$url\n"; > > > > > > printing http://epa.gov/npdes/ should redirect to > > http://cfpub.epa.gov/npdes/ but nothing happens. > > > It isn't clear from reading the documentation, but LWP::UserAgent only > handles redirection at the HTTP layer, not the HTML-layer with > http-equiv. I noticed this, but I also tried the script with 'http://www.google.com' which normally redirects to google.co.uk, but in the script just stays as google.com #! Perl/bin/perl use strict; use warnings; use Data::Dumper; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(100); $ua->max_redirect(100); my $url = 'http://www.google.com'; my $response = $ua->get($url); print "$url \n";
From: J. Gleixner on 31 Oct 2006 14:15 Nospam wrote: > I noticed this, but I also tried the script with 'http://www.google.com' > which normally redirects to google.co.uk, but in the script just stays as > google.com [...] > my $url = 'http://www.google.com'; > my $response = $ua->get($url); > print "$url \n"; You expect get() to overwrite your $url variable? Or are you saying that the content in $response isn't from google.co.uk? Possibly, 'google.co.uk' might be found in the $response.
From: Nospam on 31 Oct 2006 15:29
"J. Gleixner" <glex_no-spam(a)qwest-spam-no.invalid> wrote in message news:4547a0c0$0$506$815e3792(a)news.qwest.net... > Nospam wrote: > > > I noticed this, but I also tried the script with 'http://www.google.com' > > which normally redirects to google.co.uk, but in the script just stays as > > google.com > [...] > > my $url = 'http://www.google.com'; > > my $response = $ua->get($url); > > print "$url \n"; > > You expect get() to overwrite your $url variable? Or are you saying that > the content in $response isn't from google.co.uk? > > Possibly, 'google.co.uk' might be found in the $response. My problem is how to do I show that the response has 'http://www.google.co.uk' ? how do I get response; to show the url it has redirected to? as a print statement? |