특정 엘리먼트에 마우스 휠 내리기

from time import sleep
from selenium.webdriver import ActionChains
from selenium.webdriver.common.actions.wheel_input import ScrollOrigin
from selenium.webdriver.common.by import By

height = 0
actions = ActionChains(driver)

for _ in range(30): 
    # 스크롤 내리기, actionchain 사용
    element_to_scroll = driver.find_element(By.CSS_SELECTOR,'#yDmH0d > div.VfPpkd-Sx9Kwc.cC1eCc.UDxLd.PzCPDd.HQdjr.VfPpkd-Sx9Kwc-OWXEXe-FNFY6c > div.VfPpkd-wzTsW > div > div > div > div > div.fysCi > div > div:nth-child(2) > div')
    height+=20000
    scroll_origin = ScrollOrigin.from_element(element_to_scroll)
    actions.scroll_from_origin(scroll_origin, 0, height).perform()
    sleep(2) # 로딩시간 기다려주기

Leave a Comment