samedi 22 mai 2021

Scrolldown a table inside a div tag in through Selenium in Python

I wanted to scroll till the last row of https://covid19.who.int/table using Selenium framework in python.

See below my snippet

url = 'https://covid19.who.int/table/'
Path_ChromeDriver = 'E:\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(Path_ChromeDriver)
driver.get(url)
time.sleep(10)
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
target = driver.find_element_by_xpath('//div[@role="rowgroup"]//div[@role="row"][last()]//div[@class="column_Deaths td"]/div')
driver.execute_script("arguments[0].scrollIntoView(true);", target)

But this doesn't help me to scroll down the div tag. Any help will be highly appreciated. I am looking to extract all the data from the table starting from the “Americas” row.

See screenshot for data I need.enter image description here Thanks in advance




Aucun commentaire:

Enregistrer un commentaire