use LWP::Simple;
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use strict; use warnings; use LWP::Simple; my $url = 'http://www2.mouser.com/Search/Refine.aspx?Keyword=FODM8801A'; my $html = get $url; print "$html\n";
2014-05-26T14:56:27 kimmyManche Webseiten werten den Request-Header Accept-Language aus.Kann man eigentlich bei einer mehrsprachigen WebSeite eine bestimmte Sprache definieren?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use LWP::UserAgent; my $url = 'http://www2.mouser.com/Search/Refine.aspx?Keyword=FODM8801A'; my $ua = LWP::UserAgent->new; $ua->default_header('Accept-Language' => 'de'); # deutsch $ua->agent('Mozilla/5.0'); # Sinnvollen Useragent, da manche LWP blocken my $html; my $response = $ua->get($url); if ($response->is_success) { $html = $response->decoded_content; } else { die $response->status_line; } print "$html\n";
perldoc LWP::UserAgent...
$ua->default_header( $field => $value )
This is just a short-cut for $ua->default_headers->header( $field => $value ). Example:
$ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
$ua->default_header('Accept-Language' => "no, en");
LANG=en_GB ./skript.pl