python - Selenium,滚动浏览在滚动时发生变化的动态 div
问题描述
我正在尝试制作一个 Instagram 机器人来获取某个帐户的所有关注者,现在我需要滚动到关注者框的底部以加载所有关注者,但该框最后没有唯一元素,我试图向下滚动使用向下键,但它表示该元素是可交互的。
def get_followers():
# click on the followers link
driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/header/section/ul/li[2]/a').click()
time.sleep(1)
# the followers box
scroll_box = driver.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/ul/div')
action = ActionChains(driver)
action.move_to_element(scroll_box).click().perform()
# scrolling to the end to load all element
while True:
scroll_box.send_keys(Keys.ARROW_DOWN)
get_followers()
是否有更充分的方式来滚动元素。提前致谢。
解决方案
推荐阅读
- raku - 本机 localtime() 段错误
- laravel - “无消息”错误 laravel - 尝试更新用户帐户信息
- c# - Android Xamarin 上的屏幕截图,宽系统屏幕截图
- javascript - 查找对创建 html 元素的文档的引用
- c# - kestrel vs async await c#
- mysql - mysql - 没有适当索引的长时间运行查询
- html - html - 如何从 URL 中删除 index.html
- javascript - 删除表中的行时如何使用sweetalert
- sql - Access 数据库查询:计算价格变化
- json - 如何使用 Spring Rest 获取二进制数据和 JSON