I want to get all < tr> in <tdbody>
<tr>
change every x
second , it's live-data How can I get ? it ?
table = driver.find_element(By.tag_name("tdbody")
rows = table.find_elements(By.tag_name("tr"))
Remember to get the value from the .text
attribute.
You can try this:
from selenium import webdriver
import time
driver = webdriver.<browser>()
driver.get("<website url>")
tdbody=driver.find_element_by_tag_name('table').find_element_by_tag_name("tdbody")
while True:
trs=tdbody.find_elements_by_tag_name("tr")
for tr in trs:
print(tr.text)
# It is just printing text but if you want to save then make list before while loop and append this tr.text by `list.append(tr.text)`
time.sleep(1)
#It will pause for a second and scrape again.
It is never ending loop, so be careful, you can make some condition and break that loop. By just using break
keyword
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.