Reputation: 17
HTML:
<div class="col-md-8 no-padding-991" id="status">
<b>Area:</b>
157 Meters
<sup>2</sup>
| 1689.93 Feet
<sup>2</sup>
| 0.02 Ha | 0.04 Acres | 0 Miles
<sup>2</sup>
| 0 Km
<sup>2</sup>
<br>
<b>Perimeter:</b>
56.06 Meters | 0.06 Km | 0.03 Miles | 184 Feet | 61.00 Yards
</div>
I am trying to pull that value from the Area: tag yet for some reason, when I run this code:
print("scraping calc maps")
driver.get(url)
building_specs = driver.find_element_by_id("status")
print("Building specs")
print(building_specs.text)
It only pulls "Area: --", with no numbers.
Thanks for the help!
Upvotes: 0
Views: 38
Reputation: 602
Try to do:
print("scraping calc maps")
driver.get(url)
building_specs = driver.find_element_by_id("status")
print("Building specs")
print(building_specs.get_attribute('innerHTML'))
Upvotes: 1
Reputation: 889
The reason is, the .text attribute returns only the first text literal it finds. To get a concatenated text of all child nodes, you can query the innerHTML
or innerText
attribute:
# get child HTML
print(building_specs.get_attribute("innerHTML"));
# get child Text
print(building_specs.get_attribute("innerText"));
Upvotes: 0