hey guys I'm scrapping abnb with Selenium-Python. The issue is that I want to scrap the reviews from each abnb but in order to scrap them I need to scroll down the pop up element that appears.
As you can see on the image I click the button then the pop-up element appears and then I want to scroll but I can't. Of course as you can see all the reviews don't appear and I have to scroll if I want them to appear, they also don't appear on the DevTools from google chrome unless I scroll.
I tried:
reviews_lista = []
boton_revs = driver.find_element(By.XPATH, "//button[@data-testid='pdp-show-all-reviews-button']")
boton_revs.click()
I clicked on the button that you see on the image.
I selected the whole POP UP
bloque_pop = driver.find_element(By.XPATH, "//div[@class='_14vzertx']")
I tried to scroll with this code but it didn't work
scroll = 0
while scroll < 5: # scroll 5 times
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', bloque_pop)
time.sleep(1)
scroll += 1
I also tried
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
and this too:
bloque_pop = driver.find_element(By.XPATH, "//div[@class='_14vzertx']")
for i in range(5):
#driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", bloque_pop)
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)", bloque_pop)
time.sleep(1.5)
None of them work.