I am new to using selenium. I previously wrote a scrapper using Beautiful Soup and it was working fine until I ran into "accept cookie". enter image description here
I attempted to use Selenium to click on the "X" button, and then I wanted to pass the page_source to Beautifulsoup to reuse my previous script. But my soup is still showing the page with the "accept cookie", resulting in none of the class to be able to be found.
This is the website I want to scrape: https://sturents.com/s/newcastle/newcastle?ne=54.9972%2C-1.5544&sw=54.9546%2C-1.6508
Here is the script:
driver = webdriver.Chrome(PATH)
driver.get(link)
soup = BeautifulSoup(r_more_housing.text, 'html.parser')
element = driver.find_element(By.CLASS_NAME, "new--icon-cross")
element.click()
time.sleep(10)
driver.refresh()
soup = BeautifulSoup(driver.page_source)
rooms = soup.find_all('a', class_="new--listing-item js-listing-item")
rooms would return empty string.
tried to return soup where it showed the page without clicking on button