c# - 使用 Selenium 将 Instagram 个人资料图片滚动到最后
问题描述
我需要使用 Selenium 将 Instagram 个人资料图片滚动到最后。
我正在使用这段代码:
long last_height = (long)js.ExecuteScript("return document.body.scrollHeight");
while (true) {
js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight);");
System.Threading.Thread.Sleep(1500);
long new_height = (long)js.ExecuteScript("return document.body.scrollHeight");
if (new_height == last_height) {
break;
}
last_height = new_height;
}
但是这个实现有一个问题,如果页面在 1.5 秒内没有更新,它就会停止滚动。
我注意到当页面刷新时,底部会出现一个加载图标。
是否有可能以某种方式跟踪此图标是否出现?
或者您知道问题的另一种解决方案吗?
编辑:
我注意到,在加载所有图片之前,此图标(更新图像时可见,用户不向下滚动时不可见)存在,并且当所有内容加载时它完全消失。
剩下的只是检查这个元素的存在。
解决方案
推荐阅读
- laravel - 将来如何获得 DateTimeTz 列?
- sql - SQL Server 中其他人中剩余记录总和的前 10 条记录
- php - PHP - 遍历关联数组并将每个组显示为 doc1、doc 2、doc3 和 text1 和 text 2
- node.js - 无法将 rdkafka 安装到 Windows 的节点模块中
- azure-cdn - 为什么 azure cdn 向我返回带有自定义域的旧版本文件
- python - 如何在 Ubuntu Mate (Raspberry Pi3) 上安装 PyCharm?
- google-compute-engine - 区域没有足够的资源来满足请求/资源没有准备好
- javascript - d3.js tree - How to set Y depth of a specific level?
- r - saveGIF() 返回空的 GIF
- azure-data-explorer - Azure 数据资源管理器/Kusto 时间表中的当地时间