Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get href value in Splinter?

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

Is there any api method for that?

like image 352
pixel Avatar asked Feb 16 '14 20:02

pixel


2 Answers

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']
like image 100
Pablo A. Costesich Avatar answered Oct 23 '22 08:10

Pablo A. Costesich


#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"])
like image 1
Gary02127 Avatar answered Oct 23 '22 07:10

Gary02127