【发布时间】:2016-10-28 18:14:35
【问题描述】:
我正在使用 selenium 并尝试在 instagram 上的弹出 div 内滚动。
我进入类似“https://www.instagram.com/kimkardashian/”的页面,点击关注者,然后我无法让关注者列表向下滚动。
我尝试使用 hover、click_and_hold 和其他一些技巧来选择 div,但它们都不起作用。
选择这个最好的方法是什么?
这是我迄今为止尝试过的:
driver.find_elements_by_xpath("//*[contains(text(), 'followers')]")[0].click()
element_to_hover_over = driver.find_elements_by_xpath("//*[contains(text(), 'Follow')]")[12]
hover = ActionChains(webdriver).move_to_element(element_to_hover_over)
hover.click_and_hold()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
【问题讨论】:
标签: python selenium screen-scraping