-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatchRun.js
More file actions
34 lines (27 loc) · 930 Bytes
/
batchRun.js
File metadata and controls
34 lines (27 loc) · 930 Bytes
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
// npm install d3
// run as node 6 change startDate endDate
// node ./batchRun.js
const exec = require('child_process').exec;
var d3 = require("d3");
var formatHKJC = d3.timeFormat("%Y%m%d")
var formatMonth = d3.timeFormat("%B");
var startDate = new Date(2011, 01, 1);
var endDate = new Date(2011, 12, 31);
// d3.utcDay.offset(new Date(), 1)
var range = d3.utcDay.range(startDate, endDate);
//you could remove all dates in AUGUST!
var candiDates = range.map(d => {return formatHKJC(d);});
for (let d of candiDates) {
console.time("loop start");
let theCommand = `scrapy crawl racers -a racedate=${d}`
console.log(theCommand);
const child = exec(theCommand,
(error, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
};
console.timeEnd("loop start");