What is best approach at getting the price and other attributes? i usually uset find_element_by_id("") it seems like a better idea to use the data-column tag. How would I do this?
Asked
Active
Viewed 102 times
0
-
using the id is always faster. – whackamadoodle3000 Sep 09 '17 at 00:23
-
Possible duplicate of [Is there a way to find an element by attributes in Python Selenium?](https://stackoverflow.com/questions/28426645/is-there-a-way-to-find-an-element-by-attributes-in-python-selenium) – JeffC Sep 09 '17 at 01:46
2 Answers
0
Typically, to get attribute of a specific tag you need to use get_attribute() function.
Like this:
driver.find_element_by_id("id").get_attribute("href")
You can try to follow the same logic in your case, but you might not get a focus on needed element with selenium. Big and smart companies don't want you to scrape.

Hisagr
- 601
- 6
- 13
0
I guess the prefix string in ID is a dynamic value, id is different when enter this page each time. I don't think you can use find_element_by_id("id").
You can use the 'SKU Condition' value to find the matched row at first, then to find the price cell within row, an example xpath to do that:
//table/tbody/tr[td[contains(text(), 'MP-7D1Comp')]]/td[@data-column='price']//input
use driver.find_element_by_xpath("xpath");

yong
- 13,357
- 1
- 16
- 27
-
got the API to work, but that would have been the way to do it, In fact, I could iterate through a list and get them all that way. Thanks! – Sep 09 '17 at 14:03