如何向下滚动到页面底部的位置(无限滚动,pinterest)

问题描述 投票:0回答:1

与始终滚动到底部相比,我滚动的方式要少一点吗?我不想一直滚动到底部,而是想滚动其中的50%来获取更多内容。由于美丽的汤不能满足我的需求。这是我用于向下滚动pinterest的代码。

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

  #Wait to load page
  time.sleep(scroll_pause)


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

我将不胜感激任何建议或帮助。

python-3.x selenium selenium-webdriver infinite-scroll pinterest
1个回答
0
投票
new_height = browser.execute_script("return document.body.scrollHeight / 2")
© www.soinside.com 2019 - 2024. All rights reserved.