-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyCrawler.js
More file actions
33 lines (27 loc) · 892 Bytes
/
myCrawler.js
File metadata and controls
33 lines (27 loc) · 892 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
// var http = require('http');
var https = require('https');
var fs = require('fs');
//The url we want is: 'www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
var options = {
host: 'uva.onlinejudge.org',
path: '/external/1/101.pdf',
// host: 'www.random.org',
// path: '/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
};
var file = fs.createWriteStream ( 'downloads/101.pdf');
callback = function(response) {
var str = '';
// console.log ( response );
//another chunk of data has been recieved, so append it to `str`
response.on('data', function (chunk) {
// str += chunk;
file.write ( chunk );
});
//the whole response has been recieved, so we just print it out here
response.on('end', function () {
console.log(str);
file.end();
});
}
https.request(options, callback).end();
console.log ("done");