Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created May 6, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaevseev/8463fc054805464bb7c5c1cc78731a6a to your computer and use it in GitHub Desktop.
Save ilyaevseev/8463fc054805464bb7c5c1cc78731a6a to your computer and use it in GitHub Desktop.
Read apps list from PSI-Probe HTML output and print as plain text
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
die "Usage: $0 file.html\n" if @ARGV != 1;
my $dom = XML::LibXML->load_html(
location => $ARGV[0],
recover => 1,
suppress_errors => 1,
);
my $xpath = '//div/table//tr';
my @nodes = $dom->findnodes($xpath)->to_literal_list;
shift @nodes; #..strip header
foreach (@nodes) {
my @a = split/[\r\n]+/;
my @b = map { /^\s*(.+)\s*$/ ? $1 : $_ } @a;
my @c = grep !/^\s*$/, @b;
my $d = join(' -- ', @c);
print $d, "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment