Stephen
Stephen

Reputation: 163

Printing out the value from find_element_by_xpath

With the following HTML:

<td valign='top' align='center'><A HREF='https://www.daz3d.com/i/account/orderdetail?order=7886745'>7886745</A></TD>

This is part of a table, inside of a tr which is just one of many that I need to get that line out of.

The following code works to get the URL:

product_link = product_block.find_element_by_xpath("//a[contains(@href, 'daz3d')] [1]");
print product_link

How do I show the actual text URL so I can use it to request that page?

Also, can I use a for loop to read all of the URL's into a table? If I do that, how can I be sure to NOT get the second URL in the tr (with the ">Reset<"), which is not needed?

Upvotes: 0

Views: 1297

Answers (1)

e.dan
e.dan

Reputation: 7487

Try adding .get_attribute("href"), as in:

print product_link.get_attribute("href")

Your second question is a little less clear... perhaps you are looking for the find_elements_by_xpath() which returns multiple elements?

Upvotes: 1

Related Questions