Get href value in Splinter?

I would like to get the value hreffrom an element <a>in Splinter.

Is there any api method for this?

+4
source share
2 answers

If you select items using the find_by_ * methods , the s instances returned by them . After you select the element of interest to you (most likely, an instance), refer to the property as a dictionary: ElementList ElementAPI

the_element['href']
+8
source
#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"])
+1
source

Source: https://habr.com/ru/post/1527221/


All Articles