import time
from selenium import webdriver
url = 'https://www.dns-shop.ru/catalog/17a89aab16404e77/videokarty/?p=1'
options = webdriver.FirefoxOptions()
options.set_preference("dom.webdriver.enabled", False)
driver = webdriver.Firefox(executable_path="Y:\\projects\\apppython2\\geckodriver-v0.30.0-win64\\geckodriver.exe", options=options)
from selenium.webdriver.common.by import By
try:
driver.get(url)
time.sleep(5)
SCROLL_PAUSE_TIME = 2
h = 4600
while True:
pageY = driver.execute_script("return window.pageYOffset")
nextEl = driver.find_element(By.CLASS_NAME, 'pagination-widget__show-more-btn')
driver.execute_script("window.scrollTo(0, window.scrollY + 200)")
time.sleep(SCROLL_PAUSE_TIME)
if int(pageY) >= h:
nextEl.click()
h = h + h
continue
except Exception as ex:
print(ex)
finally:
driver.close()
driver.quit()