Search code examples
pythonseleniumwebautomation

Selenium(Python) grab text inside quotations


I would like to print what you see below is the numbers inside data-userassetid, for future reference how can i print those numbers inside the quotations, anything helps

<div class = "item-card-container" data-userassetid = "50904623348">

Solution

  • You could use the following code fragment:

    elem = driver.find_element_by_class_name('item-card-container')
    asset_id = elem.get_attribute('data-userassetid')