스크롤 하는방법

ㅇ.ㅇ·2022년 7월 7일
def selenium_scroll_option():
  SCROLL_PAUSE_SEC = 3
  # 스크롤 높이 가져옴
  last_height = driver.execute_script("return document.body.scrollHeight")
  while True:
    # 끝까지 스크롤 다운
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    # 1초 대기
    time.sleep(SCROLL_PAUSE_SEC)
    # 스크롤 다운 후 스크롤 높이 다시 가져옴
    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break
    last_height = new_height
profile
기록과 정리하는것을 계속해서 하려고 노력중이에요 😊

0개의 댓글