我想使用selenium在我的python代码中提取多个国籍的文本。
例如,音乐家Zedd的案例https://www.google.com/search?q=musician + Zedd +国籍他被发现是"德国人"one_answers"俄罗斯人">
我如何提取这两个文本?
(它的div类名目前是:"bVj5Zb FozYP">
Nationality = driver.find_element(by = By.XPATH, value = "/html/body//*[contains(concat(' ', @class, ' '), ' bVj5Zb FozYP ')]").text
,
尝试:
Nationality = [ x.text for x in driver.find_elements(By.XPATH,'//*[@class="bVj5Zb FozYP"]')]