我想从Splinter 中的元素中获取href
价值。<a>
有什么api方法吗?
如果您使用find_by_* 方法选择元素,则这些返回的实例是ElementList
s。选择您感兴趣的元素(很可能是一个ElementAPI
实例)后,像字典一样访问该属性:
the_element['href']
#simplest possible working example demonstrating this in action
import splinter
b = splinter.Browser()
b.visit("http://www.google.com")
elems = b.find_by_tag("a")
for e in elems:
print(e["href"])