]> git.nbdom.net Git - nb.git/commitdiff
bin/html-table2csv
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jan 2017 15:28:20 +0000 (15:28 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jan 2017 15:28:20 +0000 (15:28 +0000)
bin/html-table2csv

index 470e938111f46dbcefb61c1820cf16bc3f5422f1..e46f2fdfa4ce1722f6d81d79fbc34124485b4c90 100755 (executable)
@@ -39,7 +39,7 @@ $main::_DATA_ = undef;
 # BEGIN
 #
 #################################################################################
-@ARGV = map {m,^\w+://, ? "curl -s '$_'" : $_} @ARGV if @ARGV;
+@ARGV = map {m,^\w+://, ? "curl -s '$_' |" : $_} @ARGV if @ARGV;
 my $html = join('',<>);
 $html =~ s/\s+/ /g;
 
@@ -54,6 +54,7 @@ for my $table ($html =~ m,<table[^>]*>(.*?)<\s*/\s*table\s*>,gi) {
 
     for my $td ($tr =~ m,<t[dh][^>]*>(.*?)<\s*/\s*t[dh]\s*>,gi) {
       $td = html2txt($td);
+      $_ = chr(194).chr(160); $td =~ s/$_/ /g;
       $td =~ s/\s+/ /g;
       $td = str_trim($td);
       push(@col,$td);