【发布时间】:2015-12-22 12:04:19
【问题描述】:
我正在使用 Selenium 和 Python 从this 网站提取医生列表。我选择选项 Specialty 并提取结果。一旦我们像 twitter 提要一样滚动页面,结果就会显示出来。我无法滚动页面来查看结果。我尝试了多种方法,例如 send_keys:
for i in range(0,15):
self.driver.find_element_by_id("doctor-matrix-section").send_keys(Keys.PAGE_DOWN)
time.sleep(1)
print 'hello'
print i
i+= 1
使用循环是因为我不知道我需要按下 PAGE DOWN 按钮多长时间。 我还尝试了另一种方法:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
我遵循的方法都没有奏效。任何帮助都会非常有用。
【问题讨论】:
-
你试过 -
driver.execute_script("window.scrollBy(0, document.body.scrollHeight);")吗?当您的网页中有特定坐标时,将使用 scrollTo。 scrollBy 按您提供的像素数滚动,例如document.body.scrollHeight。 -
我试过了,但根本不工作,该网站是使用 angularjs 开发的,这有什么影响吗?
标签: python selenium selenium-webdriver scrapy