一个元素可能有多个属性,例如: class id, name, text, href, value等等。下面以百度首页为例,打印所有包含href的元素链接。
for link in driver.find_elements_by_xpath("//*[@href]"):
print(link.get_attribute('href'))
一个元素可能有多个属性,例如: class id, name, text, href, value等等。下面以百度首页为例,打印所有包含href的元素链接。
for link in driver.find_elements_by_xpath("//*[@href]"):
print(link.get_attribute('href'))