-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (41 loc) · 1.25 KB
/
index.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
52
var prompt = require('prompt');
var colors = require('colors');
// var Nightmare = require('nightmare');
var http = require('http');
// var Promise = require('q');
// var fs = require('fs');
// var cheerio = require('cheerio');
var Promise = require('q');
var examples = require('./examples');
console.log('\n\nSelect which test you would like to run:\n'.underline.white.bold);
console.log('-- Test 1: Using request & cheerio');
console.log('-- Test 2: Simple scraping with request & cheerio');
console.log('-- Test 3: Using Nightmare & cheerio, scrape content off of an Angular site');
console.log('-- Test 4: Take screenshots as you programmatically interact with website\n');
prompt.start();
prompt.get(['test'], function (err, result) {
if (err) { return onErr(err); }
switch (result.test) {
case '1':
examples.first();
break;
case '2':
examples.second();
break;
case '3':
examples.third();
break;
case '4':
examples.fourth();
break;
case '5':
examples.fifth();
break;
default:
console.log('\nExiting\n');
}
});
function onErr(err) {
console.log(err);
return 1;
}