This repository has been archived by the owner on Aug 8, 2020. It is now read-only.
/
allo.js
51 lines (47 loc) · 1.42 KB
/
allo.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
41
42
43
44
45
46
47
48
49
50
51
/**
* Created by gregoire on 15/01/2017.
*/
var links = [];
var casper = require('casper').create({
clientScripts: ['jquery-3.1.1.min.js'],
pageSettings: {
loadImages: false
}
});
var fs = require('fs');
casper.start('http://www.allocine.fr/film/meilleurs/');
casper.then(function () {
var e = this.evaluate(function() {
var links = document.querySelectorAll('div#col_content a.no_underline');
return Array.prototype.map.call(links, function(l) {
return {name:l.textContent.trim()};
});
});
links = links.concat(e);
// var e = this.evaluate(function() {
// return $('div#col_content a.no_underline').text().trim();
// });
//links.push({name: e});
this.echo(e);
this.mouse.click('div.pager a.fr');
this.echo("ok")
});
for (var i = 1; i <= 3; ++i) {
casper.thenClick('div.pager a.fr', function () {
var e = this.evaluate(function() {
var links = document.querySelectorAll('div#col_content a.no_underline');
return Array.prototype.map.call(links, function(l) {
return {name:l.textContent.trim()};
});
});
links = links.concat(e);
this.echo(e);
this.mouse.click('div.pager a.fr');
this.echo("ok")
});
}
casper.run(function () {
this.echo(links.length);
fs.write("film.txt", JSON.stringify(links), 'w');
this.echo("finish").exit();
});