I use selenium in python to read table data from a website. I want to get data1
and data2
. I use the code like below. But I can only get the data2, the first code will print nothing. Can anyone tell me how to solve this problem? Thank you.
elem = browser.find_element_by_css_selector('td.el-table_1_column_1.is-hidden div')
print(elem.text)
elem = browser.find_element_by_css_selector('td.el-table_1_column_2 div')
print(elem.text)
<td class="el-table_1_column_1 is-hidden">
<div class="cell">data1</div>
</td>
<td class="el-table_1_column_2 ">
<div class="cell">data2</div>
</td>
Use elem.get_attribute("textContent")
to get the hidden value from node.
elem = browser.find_element_by_css_selector('td.el-table_1_column_1.is-hidden div')
print(elem.get_attribute("textContent"))
Please check the following Link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.