简体   繁体   中英

CasperJs with AWS Lambda

I use node-casperjs-aws-lambda to create my casperjs, I update the phantomjs version to 2.1.1 and I deploy the code with the basic example on Lambda, that works perfectly

But When I try to test casperJs with Amazon website it didn't work. The page does not load but in local, it's work:

// 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();

The Cloud Watch debug mod give me :

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  

I didn't understand the problem (I tried too with the original phantomjs version 1.9.8 given with the package, but I have the same problem)

Thanks

It's only a timeout problem.

I needed to adjust my timeout in configuration > advanced settings > timeout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM