From: Nospam on
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
"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

<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
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

"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?


 |  Next  |  Last
Pages: 1 2
Prev: file convesrions
Next: longest common substring