Conexion Simple a htaccess con PERL
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
$url = shift || 'http://192.168.0.1';
# setup your browser
$ua = LWP::UserAgent->new(keep_alive => 1, timeout => 300);
# what kind of browser you are
$ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a)
Gecko/20021207 Phoenix/0.5");
# a place to store cookies, if needed
$ua->cookie_jar( HTTP::Cookies->new(file => "perlcookies.dat", autosave
=> 1) );
# now build a request
$request = HTTP::Request->new( GET => $url );
# set credentials
$request->authorization_basic($username, $password);
# run browser
$response = $ua->request($request);
# and check response
if ($response->is_success) {
print $response->content, "\n";
} else {
die "failed: ", $response->message, "\n";
}
- bitfrost's blog
- Login to post comments
- 2398 reads
Comentarios recientes
8 years 33 weeks ago
9 years 5 weeks ago
9 years 5 weeks ago
9 years 5 weeks ago
10 years 20 weeks ago
11 years 28 weeks ago
11 years 28 weeks ago
11 years 29 weeks ago
12 years 24 weeks ago
12 years 32 weeks ago