2016-12-25 68 views
0

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 –

回答

0

作爲工作的例子,下面的打印腳本表中的所有 「清單#」。 我希望,這有助於。

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); 
    }) 
; 
相關問題