小编Noo*_*mer的帖子

如何在Python中使用selenium“向下滚动”某些部分?

希望你很好,我正在尝试制作一个简单的脚本,但我被困在那里,我试图滚动列表以获取更多内容,但我无法向下滚动。任何人都知道这是如何完成的。

\n

这是我的代码:

\n
import selenium\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom shutil import which\nimport time\nimport pandas as pd\nimport json\n# from fake_useragent import UserAgent\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.webdriver.common.by import By\nfrom selenium.common.exceptions import TimeoutException\nchrome_path = which(\'chromedriver\')\ndriver = webdriver.Chrome(executable_path=chrome_path)\ndriver.maximize_window()\n\ndriver.get(\'http://mapaescolar.murciaeduca.es/mapaescolar/#\')\n\ndriver.find_element_by_xpath(\'//ul[@class="nav property-back-nav floating-box pull-right"]//button\').click()\ntime.sleep(3)\ndriver.find_element_by_xpath(\'//button[@ng-click="openCloseFilters()"]\').click()\ntime.sleep(3)\ndriver.find_element_by_xpath(\'//select[@title="Ense\xc3\xb1anza"]/option[1]\').click()\n\n\n\nelement = driver.find_element_by_xpath(\'//div[@id="container1"]\')\ndriver.execute_script("return arguments[0].scrollIntoView(true);", element)\n
Run Code Online (Sandbox Code Playgroud)\n

我想向下滚动的列表:

\n

这是我想要滚动的列表

\n

python selenium scroll selenium-chromedriver selenium-webdriver

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