Skip to content

Instantly share code, notes, and snippets.

@peschee
Created May 31, 2016 13:56
Show Gist options
  • Save peschee/f3a992c2ff8033f6ebd04aa79e809fbb to your computer and use it in GitHub Desktop.
Save peschee/f3a992c2ff8033f6ebd04aa79e809fbb to your computer and use it in GitHub Desktop.
LWP browser test
#!/usr/bin/env perl
# Simple LWP browser for testing
$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("$0/0.1 " . $ua->agent);
# $ua->agent("Mozilla/8.0") # pretend we are very capable browser
$req = HTTP::Request->new(GET => $ARGV[0]);
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print $res->content;
} else {
print "Error: " . $res->status_line . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment