获取链接属性
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(6)
driver.get("https://www.baidu.com")
time.sleep(1)
# 获取多个链接
for link in driver.find_elements_by_xpath("//*[@href]"):
print(link.get_attribute('href'))
# 获取单个链接
driver.find_element_by_xpath("//*[@href]").get_attribute('href')
# 退出
driver.quit()