I have a piece of html::treebuilder::xpath code that sort of works, but isn't populating the node values properly. Here is what I am doing:
my @nodes = $tree->findnodes('//tr');
for my $node (@nodes) {
my @text = $node->findvalue('td') or next;
print dumper \@text;
next;
my @node_list = $node->findvalues('td/tr');
last;
}
When I print dumper @text (I get the same answer using a string instead of an array), it just prints all of the values in the node shoved together without breaking it into an array or anything. No matter what I do, I can't get it into @node_list, even though each dumper print line tells me it found a node. Here is the content I am trying to parse:
#(reference, not parsing)
<tr><th>Firstseen (UTC)</th><th>Version</th><th>Feodo C&C</th><th>
+Status</th><th>SBL</th><th>ASN</th><th>Country</th><th>Lastseen (UTC)
+</th></tr>
#parsing the below
<tr bgcolor="#9d9595" onmouseover="this.style.backgroundColor='#FFA200
+';" onmouseout="this.style.backgroundColor='#9d9595';"><td>2016-03-19
+ 23:44:36</td><td bgcolor="#58D3F7" align="center"><strong>D</strong>
+</td><td><a href="/host/83.172.215.87/" target="_parent" title="Show
+more information about this Feodo C&C">83.172.215.87</a></td><td
+bgcolor="#4f883f">offline</td><td bgcolor="#bc5959"><a href="http://w
+ww.spamhaus.org/sbl/sbl.lasso?query=SBL290535" target="_blank" title=
+"Spamhaus SBL: SBL290535">SBL290535</a></td><td>AS12651 IPWORLDCOM</t
+d><td><img src="images/flags/ch.gif" alt="-" title="CH (CH)" width="1
+6" height="10" /> CH</td><td>never</td></tr>
<tr bgcolor="#837b7b" onmouseover="this.style.backgroundColor='#FFA200
+';" onmouseout="this.style.backgroundColor='#837b7b';"><td>2016-03-19
+ 23:44:36</td><td bgcolor="#58D3F7" align="center"><strong>D</strong>
+</td><td><a href="/host/98.23.159.86/" target="_parent" title="Show m
+ore information about this Feodo C&C">98.23.159.86</a></td><td bg
+color="#4f883f">offline</td><td bgcolor="#4f883f">Not listed</td><td>
+AS7029 WINDSTREAM</td><td><img src="images/flags/us.gif" alt="-" titl
+e="US (US)" width="16" height="10" /> US</td><td>never</td></tr>
<tr bgcolor="#9d9595" onmouseover="this.style.backgroundColor='#FFA200
+';" onmouseout="this.style.backgroundColor='#9d9595';"><td>2016-03-19
+ 23:44:36</td><td bgcolor="#58D3F7" align="center"><strong>D</strong>
+</td><td><a href="/host/178.188.14.86/" target="_parent" title="Show
+more information about this Feodo C&C">178.188.14.86</a></td><td
+bgcolor="#4f883f">offline</td><td bgcolor="#4f883f">Not listed</td><t
+d>AS8447 TELEKOM-AT</td><td><img src="images/flags/at.gif" alt="-" ti
+tle="AT (AT)" width="16" height="10" /> AT</td><td>2016-03-24 01:19:5
+0</td></tr>
Thank you for your assistance! I am trying to break out the first seen, ip address, and offline or online status. At the moment, I can't seem to get it to even populate these values as an array in @text to push into a hash.