Reputation: 366
i got a problem with the german Amazon site.
This Url http://www.amazon.de/Angebote/b/ref=cs_top_nav_gb27?ie=UTF8&node=872398 links to the german Amazon-Deal site.
On the Site is a section called "Aktuelle Blitzangebote" which offers serval deals over the day at a specific time.
Somehow the deals within the 'ul.ulResized' (the deal in the "Aktuelle Blitzangebote box) are not loaded if I try to access them via phantomjs.
I use the following script to grab the HTML-src from the site:
var casper = require("casper").create({
pageSettings: {
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
viewportSize: {width: 1600, height: 900}
}
});
var fs = require('fs');
var address = casper.cli.args[0].replace(/\^/g,"");
console.log("Address == " + address);
casper.on('remote.message', function (msg) {
this.echo('remote message caught: ' + msg);
});
casper.start(address);
casper.wait(5000);
casper.then(function()
{
console.log("writing");
fs.write("blitz.html", this.getHTML(), "w");
console.log("done");
});
casper.run();
Can someone help me to fix this issue?
Best regards, Ogofo
Upvotes: 1
Views: 570
Reputation: 28486
You can do something like this:
var url = 'http://www.amazon.de/Angebote/b/ref=cs_top_nav_gb27?ie=UTF8&node=872398';
var casper = require('casper').create({
verbose: false,
logLevel: 'debug'
});
casper.test.comment('Starting Testing');
casper.start(url, function() {
console.log(this.getCurrentUrl());
this.test.assertHttpStatus(200, siteName + ' is up');
this.wait(5000, function(){
console.log(this.getHTML(".ulResized "));
});
});
casper.run(function() {
this.echo('So the whole suite ended.');
this.exit();
});
You should also be able to select specific <li>
by using this:
console.log(this.getHTML(".ulResized li:nth-child(1)")); //replace 1 with list order number
Upvotes: 1