-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvacationRentals.js
40 lines (37 loc) · 1.69 KB
/
vacationRentals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var casper = require('casper').create({
logLevel: "info", // Only "info" level messages will be logged
verbose: true,
pageSettings: {
javascriptEnabled: true,
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: true, // use these settings
}
});
var mainUrl = casper.cli.get("url");
var x = require('casper').selectXPath;
casper.options.viewportSize = { width: 1360, height: 768 };
casper.userAgent('Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36');
phantom.cookiesEnabled = true;
if (casper.cli.has("url")) {
vacationRentals();
}
if (!casper.cli.has("url")) {
casper.echo("\nUsage:casperjs vacationrentals.js --url=http://YourUrl.com/").exit();
}
function vacationRentals() {
casper.start(mainUrl).then(function scarp() {
this.echo((this.fetchText(x('//*[@id="wrapper"]/div[2]/div[2]/div[1]/div[2]/h1/span'))).trim());
this.echo((this.fetchText(x('//*[@id="wrapper"]/div[2]/div[2]/div[1]/div[5]/div/div[2]/div[9]/section[1]/div/div[3]/div[2]/div/div[1]/div[2]/div[1]/div/span'))).trim());
});
casper.then(function render() {
this.evaluate(function check() {
window.__utils__.echo(require('pageData').listing.address.city);
window.__utils__.echo(require('pageData').listing.address.stateProvince);
window.__utils__.echo(require('pageData').listing.address.country);
for (var i = 0; i < require('pageData').listing.contact.phones.length; i++) {
window.__utils__.echo(require('pageData').listing.contact.phones[i].phoneNumber);
}
});
})
casper.run();
};//end