Created
May 31, 2016 13:56
-
-
Save peschee/f3a992c2ff8033f6ebd04aa79e809fbb to your computer and use it in GitHub Desktop.
LWP browser test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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