更新时间:2022-06-22 07:09:42
嗯,您只需要遍历列表即可:
Well, you have to simply loop through the list:
elems = driver.find_elements_by_xpath("//a[@href]")
for elem in elems:
print(elem.get_attribute("href"))
find_elements_by_*
返回元素列表(注意"elements"的拼写).遍历列表,获取每个元素并从中获取所需的所需属性值(在本例中为href
).
find_elements_by_*
returns a list of elements (note the spelling of 'elements'). Loop through the list, take each element and fetch the required attribute value you want from it (in this case href
).