'How do I get href attribute value from the given HTML using Python+Selenium?
I have HTML as shown (modified to make it brief)
ht=<a class="title" href="http:/www.myref.com/1235" title="This is link to my ref">This is my ref</a>
Now from here, I want to extract the "http:/www.myref.com/1235"
ht.get_text()
gives me only the text part This is my ref
.
Solution 1:[1]
If ht
is a webelement then,
ht.get_attribute('href')
should give you http:/www.myref.com/1235
Since you are getting TypeError: 'NoneType' object is not callable
This could mean either
ht
is not a web element.ht
is not rendered properly.
Put some delay before ht
and try again with ht.get_attribute('href')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cruisepandey |