'How do I extract multiple div class from google search?

I'd like to extract multiple nationalities to text on my python code using selenium.

for example, musician Zedd's case https://www.google.com/search?q=musician+Zedd+nationality

He is found to be 'German' and 'Russian'

How do I extract both texts?

(its' div class name is currently : "bVj5Zb FozYP")

Nationality = driver.find_element(by = By.XPATH, value = "/html/body//*[contains(concat(' ', @class, ' '), ' bVj5Zb FozYP ')]").text

Best,



Solution 1:[1]

Try:

Nationality = [ x.text for x in driver.find_elements(By.XPATH,'//*[@class="bVj5Zb FozYP"]')]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1