2017-01-31 135 views
2

我用node-casperjs-aws-lambda創建我casperjs,我更新phantomjs版本爲2.1.1,我用部署在λ基本示例的代碼,完美的作品CasperJs與AWS LAMBDA

但是當我嘗試測試casperJs與亞馬遜網站它沒有工作。該頁面沒有加載,但在本地,它的工作:

// Simple Javascript example 
var casper = require('casper').create(); 

casper.options.verbose = true; 
casper.options.logLevel ="debug"; 

casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0'); 

var amazonProduct = 'https://www.amazon.fr/gp/product/B017DBB1S8'; 

console.log('Loading a web page: ' + amazonProduct); 
// Ouvre la page produit 
casper.start(amazonProduct, function() 
{ 
    this.echo('Page title is: ' + this.getTitle()); 
}); 

casper.run(); 

雲觀看調試MOD給我:

Loading a web page: https://www.amazon.fr/gp/product/B017DBB1S8 

2017-01-31T22:04:30.553Z  
[36m[info][0m [phantom] Starting... 
[36m[info][0m [phantom] Running suite: 2 steps 
[32;1m[debug][0m [phantom] opening url: https://www.amazon.fr/gp/product/B017DBB1S8, HTTP GET 
[32;1m[debug][0m [phantom] Navigation requested: url=https://www.amazon.fr/gp/product/B017DBB1S8, type=Other, willNavigate=true, isMainFrame=true 

2017-01-31T22:04:31.190Z [32;1m[debug][0m [phantom] url changed to "https://www.amazon.fr/gp/product/B017DBB1S8" 

2017-01-31T22:04:43.074Z [32;1m[debug][0m [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false 

END RequestId: 3b415fbd-e801-11e6-9736-75ef38e95128 

Duration: 15001.48 ms Billed Duration: 15000 ms Memory Size: 128 MB Max Memory Used: 74 MB 

我不明白的問題(我原來phantomjs版本嘗試過1.9.8與給定的包,但我有同樣的問題)

感謝

回答

2

這只是一個超時問題。

我需要調整我的配置超時>高級設置>超時

+0

僅供參考。當我爲亞馬遜網站編寫爬蟲程序時,我發現亞馬遜網站阻止了我的請求,因此我使用Tor動態切換IP。 – narainsagar

+0

感謝您的建議。 – MatinGarrix