Hey I'm trying to set this up so that it will pull out the value for useage, heres the code.
<tr class="data-point">
<th class="x-value" data-value="1391212800" data-label="Feb" data-description="February 2014"> February 2014 </th>
<td class="y-value" data-value="164" data-tooltip-name="usage" data-tooltip-index="2" data-series="runtime" data-description="164 hours"> 164 hours </td>
<td class="y-value" data-value="16.0" data-tooltip-name="usage" data-tooltip-index="1" data-series="savings" data-description="16 hours"> 16 hours </td>
</tr>
So I need to extract and set to a variable(useage) data-series="runtime"'s data-value end result should be: useage = 164
Nodes have a []
method that returns attribute values.
The following shows using the method to get the data-value attribute:
usage = page.find('td[data-series="runtime"]')['data-value']
p usage
#=> "164"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With