#1 2015-08-20 20:17:09

Nelson
Member
Registered: 2015-04-21
Posts: 21

NeoPlugins - Parsing an HTML table

Hi,

I got an HTML table that looks pretty much like this:

<table>
   <tr>
      <th width="120">Date
      <th>Peak<br>Upload (MB)
      <th>Peak<br>Download (MB)
      <th>Peak<br>Combined (MB)
      <th>Off-Peak<br>Combined (MB)
   </tr>
   <tr>
      <td><a href="usage?month=1409544000" title="Click month to show daily breakdown">September 2014</a></td>
      <td>334.55</td>
      <td>4016.56</td>
      <td class="pcom">4351.12</td>
      <td class="ocom">30818.33</td>
   </tr>
   <tr>
      <td><a href="usage?month=1412136000" title="Click month to show daily breakdown">October 2014</a></td>
      <td>488.58</td>
      <td>4798.79</td>
      <td class="pcom">5287.36</td>
      <td class="ocom">55768.62</td>
   </tr>
   <tr>
      <td><a href="usage?month=1414814400" title="Click month to show daily breakdown">November 2014</a></td>
      <td>793.08</td>
      <td>6912.35</td>
      <td class="pcom">7705.43</td>
      <td class="ocom">31341.38</td>
   </tr>
   <tr>
      <td><a href="usage?month=1417406400" title="Click month to show daily breakdown">December 2014</a></td>
      <td>530.16</td>
      <td>4599.28</td>
      <td class="pcom">5129.44</td>
      <td class="ocom">51688.09</td>
   </tr>
   <tr>
      <td><a href="usage?month=1420084800" title="Click month to show daily breakdown">January 2015</a></td>
      <td>421.99</td>
      <td>4433.42</td>
      <td class="pcom">4855.41</td>
      <td class="ocom">55802.25</td>
   </tr>
   <tr>
      <td><a href="usage?month=1422892800" title="Click month to show daily breakdown">February 2015</a></td>
      <td>795.39</td>
      <td>4705.91</td>
      <td class="pcom">5501.30</td>
      <td class="ocom">55786.28</td>
   </tr>
   <tr>
      <td><a href="usage?month=1425182400" title="Click month to show daily breakdown">March 2015</a></td>
      <td>2323.08</td>
      <td>3136.77</td>
      <td class="pcom">5459.85</td>
      <td class="ocom">47262.82</td>
   </tr>
   <tr>
      <td><a href="usage?month=1427860800" title="Click month to show daily breakdown">April 2015</a></td>
      <td>482.75</td>
      <td>4835.06</td>
      <td class="pcom">5317.80</td>
      <td class="ocom">48810.40</td>
   </tr>
   <tr>
      <td><a href="usage?month=1430452800" title="Click month to show daily breakdown">May 2015</a></td>
      <td>419.22</td>
      <td>5143.85</td>
      <td class="pcom">5563.07</td>
      <td class="ocom">39057.25</td>
   </tr>
   <tr>
      <td><a href="usage?month=1433131200" title="Click month to show daily breakdown">June 2015</a></td>
      <td>706.41</td>
      <td>5593.51</td>
      <td class="pcom">6299.92</td>
      <td class="ocom">51738.25</td>
   </tr>
   <tr>
      <td><a href="usage?month=1435723200" title="Click month to show daily breakdown">July 2015</a></td>
      <td>657.12</td>
      <td>5077.69</td>
      <td class="pcom">5734.82</td>
      <td class="ocom">27691.05</td>
   </tr>
   <tr>
      <td><a href="usage?month=1438401600" title="Click month to show daily breakdown">August 2015</a></td>
      <td>332.99</td>
      <td>3781.16</td>
      <td class="pcom">4114.15</td>
      <td class="ocom">28483.11</td>
   </tr>
   <tr>
      <td class="total">Total</td>
      <td class="total">8285.32</td>
      <td class="total">57034.35</td>
      <td class="total_pcom">65319.67</td>
      <td class="total_ocom">524247.83</td>
   </tr>
</table>

And I was wondering if there's a way of getting all the pcom and ocom data using npXMLs or if ots another way of doing this with Neobook or a NeoPlugin (?)

Regards.

Offline

#2 2015-08-20 21:29:23

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: NeoPlugins - Parsing an HTML table

Hello Nelson,

Probably npXmls can do the job too, but I think npRexp can be better here. I modified one of the npRexp samples in order to search for "pcom" data in your HTML table. Take a look if you wanted here:

Sample download

I just modified a little the application sample, then probably we can get better results: it's a question of time, some npRexp study and adapt the plugin to our own publication.

Offline

#3 2015-08-20 22:31:57

Nelson
Member
Registered: 2015-04-21
Posts: 21

Re: NeoPlugins - Parsing an HTML table

Wow, thats pretty good, I was hoping to be able to use npXMLs since I dont actually have Rexp... I'm just having a terrible time trying to understand the way XMLs work, even with the samples...

Offline

#4 2015-08-20 22:40:39

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: NeoPlugins - Parsing an HTML table

Hello Nelson,

I think we can use npXmls but they require too much work than use npRexp. npXmls is a very complex plugin which allow us to parse arbitrary XML, but requires some work in order to get ready for what we wanted. npRexp is more close up to this kind of problems, since we can provide a regular expression of our search query and simply get the available matches.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.