Get href value in Splinter?

本小妞迷上赌 提交于 2019-12-05 00:09:39

问题


I would like to get href value from <a> element in Splinter.

Is there any api method for that?


回答1:


If you are selecting elements using the find_by_* methods, instances returned by these are ElementLists. After you select the element you are interested in (most probably an ElementAPI instance), access the property like a dictionary:

the_element['href']



回答2:


#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"])


来源:https://stackoverflow.com/questions/21816397/get-href-value-in-splinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!