Mercurial > hg > lukkari
changeset 4:dd2bce7ec0c8
Removed http fetching feature, it's not really useful here.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 Jan 2011 20:55:09 +0200 |
parents | 3d0904d29591 |
children | 3d6a83eaa2ba |
files | parsedata.pl |
diffstat | 1 files changed, 4 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/parsedata.pl Tue Jan 11 20:54:02 2011 +0200 +++ b/parsedata.pl Tue Jan 11 20:55:09 2011 +0200 @@ -5,11 +5,8 @@ # use strict; use Data::Dumper; -use LWP::UserAgent; use HTML::Entities; -my $userAgent = "Lukkari/0.7"; - sub urlencode($) { @@ -116,26 +113,6 @@ return $res; } - -sub http_fetch($) -{ - my $agent = LWP::UserAgent->new; - $agent->agent($userAgent); - $agent->timeout(10); - - my $req = HTTP::Request->new(GET => $_[0]); - $req->user_agent($userAgent); - my $res = $agent->request($req); - - if ($res->is_success) { - return $res->content; - } else { - print STDERR "HTTP request failed: [".$res->code."] ".$res->message."\n"; - return undef; - } -} - - sub html_find_node($$$); sub html_find_node($$$) @@ -237,7 +214,7 @@ } } -die("Usage: $0 [options] <filename|URI> +die("Usage: $0 [options] <filename> -php Output a PHP include file with data in arrays (default) -simple Output simple tabled output for easy parsing. @@ -251,13 +228,9 @@ my $data; -if ($opt_filename =~ /^(http|https):/) { - $data = http_fetch($opt_filename) or die("Could not fetch: $opt_filename\n"); -} else { - open(my $fh, '<', $opt_filename) or die("Error opening '$opt_filename': $!\n"); - $data = do { local $/; <$fh> }; - close($fh); -} +open(my $fh, '<', $opt_filename) or die("Error opening '$opt_filename': $!\n"); +$data = do { local $/; <$fh> }; +close($fh); die("No data in input.\n") unless (defined($data) && $data ne "");