I'm trying to scrape a webpage that has a React element that hides the dropdown after few seconds.
This is what you see when you first get to the page and the tab I would like to scrape.
I'm trying to scrape the part that says Don't miss out! 24 people are viewing this event
After few seconds, the tab disappears and gets replaced by another dropdown element that says Get notified at the right price!
The source code reveals the view count drop down as being hidden after few seconds. The top of the code shows the new dropdown while the bottom with the 'hide' in the div class being the dropdown I want to scrape.
I've tried getting the div class = "urgency-component-container but due to it being hidden, it returns nothing. I've also tried getting the div class = "dropdown-header-item" but that was returning nothing as well.
I've tried getting the XPath to the dropdown-header-item (//*[@id="dropdown-header"]/div/div1) but that didn't work either.
How can I scrape the dropdown that "hides" after few seconds? Thanks
EDIT:
the website url is : https://www.stubhub.com/anaheim-ducks-tickets-anaheim-ducks-anaheim-honda-center-11-14-2019/event/104217448/?sort=price%20asc
The code I used was
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
url = 'https://www.stubhub.com/anaheim-ducks-tickets-anaheim-ducks-anaheim-honda-center-11-14-2019/event/104217448/?sort=price+asc'
driver.get(url)
content = driver.find_element_by_class_name('dropdown-header-item')
If I execute the code straightaway I get an error
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".dropdown-header-item"}
but if I wait few seconds and run it then I get
Get notified at the right price!Set price alert


