]> git.nbdom.net Git - nb.git/commitdiff
Option href
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 4 Jun 2023 19:05:06 +0000 (21:05 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 4 Jun 2023 19:05:06 +0000 (21:05 +0200)
bin/html2csv

index c20d8d22a0d97545dcac0ad55b0afc96e2a7503a..c54d16eb807584f08a83ffc182f8b8063264e57d 100755 (executable)
@@ -81,12 +81,19 @@ for my $table ($html =~ m,<${T1}${exp1}[^>]*>(.*?)<\s*/\s*${T1}\s*>,gi)
   next if defined $Opt{'num'} and $Opt{num} and $Opt{num} != $table_num;
 
   $table = "<>$table</>" unless $T2;
-  for my $tr ($table =~ m,<(${T2})${exp2}[^>]*>(.*?)<\s*/\s*${T2}\s*>,gi) {
+  for my $tr ($table =~ m,<(${T2})${exp2}[^>]*>(.*?)<\s*/\s*${T2}\s*>,gi)
+  {
     my @col;
     print "$table_num " if $Opt{'print-num'};
 
        $tr = "<>$tr</>" unless $T3;
        my $count = 0;
+
+    #@_ = $tr =~ m,(<td[^>]*>)\s*<a\s+href="([^"]+)"[^>]*>(.*?)</a>,;
+    #die @_ if @_;
+    $tr =~ s,<td[^>]*>\s*<a\s+href="([^"]+)"[^>]*>(.*?)</a>,<td>$1</td><td>$2,g
+       if $Opt{href};
+
     for my $td ($tr =~ m,<${T3}${exp3}[^>]*>(.*?)<\s*/\s*${T3}\s*>,gi)
     {
       $td = html2txt($td) unless $Opt{html};
@@ -221,7 +228,8 @@ Quick usage:
 
 =head1 OPTIONS
 
- -option[tag|T=s] Default: table
+ -option[tag|T=s] table|dl Default: table
+ -option[href!] Treat href as a column
  -option[sep|s=s] Default: tab (\t)
  -option[html!] Escape html (default: yes)
  -option[num|n=i] Only dump table number