显示菜鸟教程的底部文字By.CSS_SELECTOR
cess select 不需要滚动到底部 直接可以获得
test_loc='[href="//www.runoob.com/web/web-buildingprimer.html"]>h4'
# 显示底部的文字 # [href="//www.runoob.com/web/web-buildingprimer.html"]>h4 # 导包 from selenium import webdriver from selenium.webdriver.common.by import By # 定义类 class GetEle: def __init__(self,driver): self.driver=driver def get_e(self,loc): e=driver.find_element(By.CSS_SELECTOR,loc) print(e.text) # 调用 if __name__ == '__main__': # 调用driver driver=webdriver.Chrome() driver.get("https://www.runoob.com/") # 实例化类 web_e=GetEle(driver) test_loc='[href="//www.runoob.com/web/web-buildingprimer.html"]>h4' web_e.get_e(test_loc)