与始终滚动到底部相比,我滚动的方式要少一点吗?我不想一直滚动到底部,而是想滚动其中的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
我将不胜感激任何建议或帮助。
new_height = browser.execute_script("return document.body.scrollHeight / 2")