I have a html doc containing table element. The table has various properties like 'state', 'port', 'ip' etc. As part of my academic studying, I need to write a python program that scanning the table and write the data into log file.
I'm using beautifulsoup4, and I managed to write all the properties I needed except the IP.
The reason for that is that the IP divided to multiple elements and there is difficulty to discover a pattern.
Here's the html code (I presented only the IP td)
<tr class="" rel="21658486">
<td>
<span>
<style>
.pcx4 {
display: none;
}.AHsU {
display: inline;
}
</style>
<span style="display: none">47</span>
<span class="pcx4">47</span>
<div style="display: none">47</div>
<span style="display: none">105</span>
<span class="pcx4">105</span>
<span class="pcx4">164</span>
<span></span>
<span style="display: inline">185</span>
<span style="display: none">238</span>
<span></span>
<span style="display: none">243</span>
<span></span>
<span class="205">.</span>
<span class="AHsU">28</span>
<span></span>
<span style="display: none">180</span>
<span class="pcx4">180</span>
<div style="display: none">180</div>
<span style="display: inline">.</span>
<span style="display: inline">193</span>
<span class="208">.</span>
<span class="AHsU">95</span>
</span>
</td>
</tr>
The IP for this (the first) td is: 185.28.193.95
another td is: (can't find a pattern)
<td>
<span>
<style>
.RoUm {
display: none;
}.LqwJ {
display: inline;
}.GElR {
display: none;
}.fOJi {
display: inline;
}.vLOp {
display: none;
}.i5lO {
display: inline;
}.A8Pf {
display: none;
}.GvPD {
display: inline;
}
</style>
<span></span>
<div style="display: none">129</div>
<span style="display: none">131</span>
<span class="GElR">131</span>
<span></span>
<span></span>
<span></span>
<span class="LqwJ">189</span>
<span class="A8Pf">201</span>
<div style="display: none">201</div>
<span class="151">.</span>
<span class="A8Pf">28</span>
<div style="display: none">28</div>
219
<span style="display: inline">.</span>
<span class="LqwJ">255</span>
<span class="148">.</span>
<span style="display: inline">63</span>
<span></span>
</span>
</td>
Thank's for ther helpers. I repeat that this is for an academic studying and no harm is done :)