"""翻页截图整个页面"""# 获取页面的宽度和高度page_width = web_driver.execute_script("return document.body.scrollWidth")page_height = web_driver.execute_script("return document.body.scrollHeight")# 开启设备模拟web_driver.execute_cdp_cmd('Emulation.setDeviceMetricsOverride',{'mobile': False, 'width': page_width, 'height': page_height,'deviceScaleFactor': 1})# 截图res = web_driver.execute_cdp_cmd('Page.captureScreenshot', {'fromSurface': True})img_base64 = res['data']# 恢复页面到原始状态web_driver.execute_cdp_cmd('Emulation.clearDeviceMetricsOverride', {})