我想在本网站的底部表格中使用Horseman和PhantomJS进行报废。我该怎么办?

问题描述:

https://panthers.strmarketplace.com/Permanent-Seat-Licenses/For-Sale.aspx我想在本网站的底部表格中使用Horseman和PhantomJS进行报废。我该怎么办?

底部表格需要滚动显示更多数据。这是我到目前为止已经编写的代码:

horseman 
    .open("https://panthers.strmarketplace.com/Permanent-Seat-Licenses/For-Sale.aspx") 
    .waitForSelector('div.ui-grid-cell-contents') 
    .text('div.ui-grid-cell-contents.ng-binding.ng-scope') 
    .then(function(data) { 
     console.log(data); 
    }); 

我有什么补充,或改进,以便在所有滚动表格,并从细胞中的所有数据?

更新了,babkov(返回undefined):

var Horseman = require("node-horseman"); 
var horseman = new Horseman({timeout: 50000}); 

horseman 
.open("https://texans.seasonticketrights.com/Permanent-Seat-Licenses/For-Sale.aspx") 
.waitForSelector("div.ui-grid-cell-contents.ng-binding.ng-scope") 
.evaluate(function() { 
    return angular.element($("div.ui-grid-canvas").get(0)).scope().rowContainer.visibleRowCache; 
}) 
.then(function(item) { 
    console.log(item); 
}); 
+0

如果我是你,我最好试着直接从Angular Scope中获取数据,而不是滚动。这会给你速度和可靠性。 如果您在Chrome DevTools中打开该页面,则Console中的以下命令将为您提供表日期: angular.element($('。ui-grid-canvas')。get(0))。scope()。rowContainer。 visibleRowCache –

+0

@ a-bobkov如何在Node.js中做到这一点? –

+0

骑手,你正在使用,有一个函数“评估” - https://github.com/johntitus/node-horseman#evaluatefn-arg1-arg2 –

作为工作的例子,下面的打印脚本表中的所有 “清单#”。 我希望,这有助于。

var Horseman = require("node-horseman"); 
var horseman = new Horseman({timeout: 50000}); 

horseman 
    .open("https://texans.seasonticketrights.com/Permanent-Seat-Licenses/For-Sale.aspx") 
    .waitForSelector("div.ui-grid-cell-contents.ng-binding.ng-scope") 
    .evaluate(function() { 
     return angular.element($("div.ui-grid-canvas").get(0)).scope().rowContainer.visibleRowCache.map(function(listing) {return listing.entity.ListingID;}).join(','); 
    }) 
    .then(function(listingIDs) { 
     console.log(listingIDs); 
    }) 
;