Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active August 29, 2015 14:08
Show Gist options
  • Save paveljurca/0885b2528ed697e344f3 to your computer and use it in GitHub Desktop.
Save paveljurca/0885b2528ed697e344f3 to your computer and use it in GitHub Desktop.
HTTP requests; quick and dirty
#!/usr/bin/perl
use LWP::UserAgent;
$req = HTTP::Request->new(
'HEAD' => 'http://fis.vse.cz'
);
$res = LWP::UserAgent->new(
agent => 'Googlebot/2.1'
)->request($req);
print $req->as_string,
$res->as_string;
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
## WHOIS via HTML form
$_ = new LWP::UserAgent->request(POST(
'http://www.gigaserver.cz/whois/',
Content_Type => 'form-data',
Content => [
dost_domain => 'jurcapavel',
dost_tld => 'cz',
volba => 'OVĚŘIT'
]
))->content;
#extract the WHOIS dump \
#from the HTML content
s/.*vypis-whois\">//sg;
s/[\n\r]+<\/pre>.*/\n/sg;
print;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment