小编김정석*_*김정석的帖子

为什么使用 python selenium 的 execute_script("return document.body.scrollHeight") 返回 0

在此处输入图像描述。下面是我的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() 的正确结果。要显示图像,请单击“在此处输入图像描述”

python selenium

3
推荐指数
1
解决办法
8334
查看次数

标签 统计

python ×1

selenium ×1