Leser: 21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sub check_uri_status {
my $self = shift;
my $uri = $self->query->param('uri') or die("Missing URI.");
# create the user agent we want to use to check the websites
my $ua = LWP::UserAgent->new();
$ua->default_header(ACCEPT_LANGUAGE => 'en');
$ua->max_redirect(24);
my $req = HTTP::Request->new(GET => $uri);
$req->header('Accept' => 'text/html');
# send request
my $res = $ua->request($req);
my $result = $res->status_line();
return $result;
} # /check_uri_status
1
2
3
4
5
6
7
8
9
10
# create the user agent we want to use to check the websites
my $ua = LWP::UserAgent->new(agent => 'Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00');
$ua->default_header(ACCEPT_LANGUAGE => 'en');
$ua->max_redirect(24);
my $req = HTTP::Request->new(GET => $uri);
$req->header('Accept' => 'text/html');
my $res = $ua->head( $uri );
return $res->status_line();
2009-06-30T06:53:50 pktmhttp://www.praxisdienst.co.uk/ 404 Not Found
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Data::Dumper; my $ua = LWP::UserAgent->new(); my $header = $ua->head("http://www.praxisdienst.co.uk"); print Dumper($header);
2009-06-30T07:29:21 skirnir2009-06-30T06:53:50 pktmhttp://www.praxisdienst.co.uk/ 404 Not Found
Ich bekomme mit folgendem Code:
Code (perl): (dl )1 2 3 4 5 6 7 8 9 10 11 12#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Data::Dumper; my $ua = LWP::UserAgent->new(); my $header = $ua->head("http://www.praxisdienst.co.uk"); print Dumper($header);
einen 302 zurück. Was liefert der bei dir?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
~ HEAD -USsed -H Accept-Language:en http://www.praxisdienst.co.uk/
HEAD http://www.praxisdienst.com/index.php?sid=7568afd087aed24a3522f29022a77658&
lang=3&cur=3
Accept-Language: en
User-Agent: lwp-request/5.824 libwww-perl/5.826
HEAD http://www.praxisdienst.co.uk/ --> 302 Found
HEAD http://www.praxisdienst.com/index.php?sid=7568afd087aed24a3522f29022a77658&
lang=3&cur=3 --> 404 Not Found
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection: close
Date: Tue, 30 Jun 2009 07:31:44 GMT
Pragma: no-cache
Server: Apache/2.2.3 (Linux/SUSE)
Content-Type: text/html
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Client-Date: Tue, 30 Jun 2009 07:31:43 GMT
Client-Peer: 193.110.7.74:80
Client-Response-Num: 1
Set-Cookie: sid=4598b8a392eed3e3dc489335be4d8a79; path=/
Set-Cookie: sid_key=oxid; path=/
X-Powered-By: PHP/5.2.5
1
2
3
4
lwp-request -s -e -d \
-H "User-Agent: User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8.1.19) Gecko/20081202 Iceweasel/2.0.0.19 (Debian-2.0.0.19-0etch1)" \
-H "Accept-Language: de,en;q=0.8,es;q=0.6,en-us;q=0.4,de-de;q=0.2" \
http://www.praxisdienst.co.uk/
2009-06-30T07:49:50 GwenDragonJa logisch geht es mit de,en. Dann kommt es nämlich in Deutsch.