獲取鏈接屬性
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)
# 獲取多個(gè)鏈接
for link in driver.find_elements_by_xpath("http://*[@href]"):
print(link.get_attribute('href'))
# 獲取單個(gè)鏈接
driver.find_element_by_xpath("http://*[@href]").get_attribute('href')
# 退出
driver.quit()