Reputation: 13
I am working on a web scraper on Python using selenium and I want to scrape a specific element (data-car-id
) from a div which I can actually locate using the Xpath
Upvotes: 1
Views: 82
Reputation: 489
First you must find the element using whatever method you would like, xpath
, id
, class_name
, etc. Next, just use the .get_attribute
method, it should look like this:
element = browse.find_element_by_class_name("listing-item")
element.get_attribute('data-car-id')
Upvotes: 1