在此处输入图像描述。下面是我的python代码。
get()
运作良好。而表演后execute_script("return document.body.scrollHeight")
,又lastHeight
回来了0
。chromedriver 网页上的移动是没有的。然后newHeight
也返回0
。他们为什么回来0
?
def getVideoData(self):
self.chromeBrowser.get(self.videoTab)
lastHeight = self.chromeBrowser.execute_script("return document.body.scrollHeight")
print(lastHeight)
while True:
self.chromeBrowser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
self.chromeBrowser.implicitly_wait(0.5)
newHeight = self.chromeBrowser.execute_script("return document.body.scrollHeight")
print(newHeight)
if newHeight == lastHeight:
break
lastHeight = newHeight
Run Code Online (Sandbox Code Playgroud)
图像显示了 get() 的正确结果。要显示图像,请单击“在此处输入图像描述”