Subject: | LWP::UserAgent www redirect does not work for www.sprachreisen.de |
Date: | Tue, 01 Mar 2011 10:53:30 +0100 |
To: | bug-libwww-perl [...] rt.cpan.org |
From: | eleonora45 [...] gmx.net |
Hi,
The situation is, that www.sprachreisen.de tells, it is moved permanently to www.medienpartner.de, however in the browser www.medienpartner.de gives in the browser a different page, than www.sprachreisen.de.
I am not able to get the correct www.sprachreisen.de page using LWP::UserAgent.
I get the correct page using:
telnet www.sprachreisen.de 80
Trying 83.137.169.125...
Connected to www.sprachreisen.de.
Escape character is '^]'.
GET / HTTP/1.0
Host:www.sprachreisen.de
(ret)
(ret)
Attached my simple program. I can not understand, why the browser and telnet can get the right page, while LWP::UserAgent can not.
Thanks in advance, eleonora
--------------------
#
#telnet www.sprachreisen.de 80
#Trying 83.137.169.125...
#Connected to www.sprachreisen.de.
#Escape character is '^]'.
#GET / HTTP/1.0
#Host:www.sprachreisen.de
#(ret)
#(ret)
#
#
# telnet www.sprachreisen.de 80
#Trying 83.137.169.125...
#Connected to www.sprachreisen.de.
#Escape character is '^]'.
#GET / HTTP/1.0
#
#HTTP/1.0 301 Moved Permanently
#Date: Tue, 01 Mar 2011 09:12:00 GMT
#Server: Apache
#X-Powered-By: PHP/5.2.6-1+lenny9
#Status: 301 Moved Permanently
#Location: http://www.medienpartner.de
#Vary: Accept-Encoding
#Content-Length: 0
#Connection: close
#Content-Type: text/html
#
#Connection closed by foreign host.
#
#
#
use strict;
use LWP::Simple;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
$ua->timeout(100);
$ua->env_proxy;
my $name = $ARGV[0];
if(head($name)){
print "$name exists\n";
} else{
print "$name does not exist\n";
}
my $ref = $ua->requests_redirectable;
print Dumper($ref);
push @{ $ua->requests_redirectable }, 'POST';
my $response = $ua->get($name);
if ($response->is_success) {
my $beg = substr($response->decoded_content,0,80);
print "success, $beg\n";
# print $response->decoded_content; # or whatever
}
else {
die $response->status_line;
}
#Result:
#perl webgetsimple1.pl http://www.sprachreisen.de
#http://www.sprachreisen.de does not exist
#$VAR1 = [
# 'GET',
# 'HEAD'
# ];
#success, 3974:bad
---------------------------
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone