Selenium python3. Не прокручивается страница youtube.com

Есть код, который должен просто прокручивать страницу вниз:

from selenium import webdriver
from time import sleep

driver=webdriver.Chrome()
driver.get('https://youtube.com')

SCROLL_PAUSE_TIME = 0.2

# Get scroll height
last_height = driver.execute_script("return document.body.scrollHeight")

while True:
    # Scroll down to bottom
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

    # Wait to load page
    sleep(SCROLL_PAUSE_TIME)

    # Calculate new scroll height and compare with last scroll height
    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break
    last_height = new_height

У меня не работает если подключаться к youtube.com. Но если попробовать другой сайт, например meduza.io, то все работает. В чем может быть проблема?


Ответы (0 шт):