How to scroll down with Phantomjs to load dynamic content
2024-09-25 02:44:13
page.open('http://example.com/?q=houston', function () {
// Checks for bottom div and scrolls down from time to time
window.setInterval(function() {
// Checks if there is a div with class=".has-more-items"
// (not sure if this is the best way of doing it)
var count = page.content.match(/class=".has-more-items"/g);
if(count === null) { // Didn't find
page.evaluate(function() {
// Scrolls to the bottom of page
window.document.body.scrollTop = document.body.scrollHeight;
});
}
else { // Found
// Do what you want
...
phantom.exit();
}
}, 500); // Number of milliseconds to wait between scrolls
});
最新文章
- vc++ 判断文件或是文件夹是否存在,比较好的做法
- SQL Server创建复合索引时,复合索引列顺序对查询的性能影响
- 在configure distribution时遇到错误,不能打开sql agent
- [转载]&; 引用 取地址
- 2014-2015 Codeforces Trainings Season 2 Episode 7 G Gophers --线段树
- SmartGit STUDY
- 信号之alarm和pause函数
- Java常见面试题总结
- hadoop,yarn和vcpu资源配置
- XListview的下拉刷新、上拉加载、用Pull解析XML
- Bootstrap——一款超好用的前端框架
- C语言第一次博客作业 陈张鑫
- HDOJ 1217 Arbitrage (最短路)
- MongoDB 常用的几大GUI工具
- JMeter 逻辑控制之While循环控制器(While Controller)
- 斗鱼宣布获C轮15亿融资 直播行业进入资本时代
- weblogic在64位windows的设置
- [转] 机器学习是什么——周志华
- Golang之实现(链表)
- Android编程 高德地图 中如何重写 定位按键 的触发事件 (com.amap.api.maps2d.LocationSource)点击定位后不仅定位在地图中心点上而且可以设置地图的缩放大小和提示