如何使用selenium xpath复制文本?
当我写作的时候driver.find_elements_by_xpath("//div[@class='rankingItem-value js-countable']").text
我得到下一个错误:Traceback (most recent call last):
File "", line 15, in
AttributeError: 'list' object has no attribute 'text'
完整代码:from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
driver.get('https://www.similarweb.com/')
driver.find_element_by_id("js-swSearch-input").send_keys("www.pornhub.com")
driver.find_element_by_css_selector("button.swSearch-submit").click()
#self.driver.implicitly_wait(30)
time.sleep(10)
content = driver.find_elements_by_xpath("//div[@class='rankingItem-value js-countable']").text
print(content)
我需要复制网站的全球排名表,“22”之一。怎样?