Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require('http');
- var async = require('async');
- var fs = require('fs');
- async.parallel([
- function(callback){
- var options = {
- host: 'onet.pl',
- port: 80,
- path: '/',
- method: 'GET'
- };
- var req = http.request(options, function(res) {
- console.log('STATUS: ' + res.statusCode);
- console.log('HEADERS: ' + JSON.stringify(res.headers));
- res.setEncoding('utf8');
- res.on('data', function (chunk) {
- console.log('BODY: ' + chunk);
- fs.writeFile('/tmp/onet.txt', chunk, function (err) {
- if (err) throw err;
- console.log('It\'s saved!');
- });
- });
- });
- req.end();
- callback(null,"onet");
- },
- function(callback){
- var options = {
- host: 'google.com',
- port: 80,
- path: '/',
- method: 'GET'
- };
- var req = http.request(options, function(res) {
- console.log('STATUS: ' + res.statusCode);
- console.log('HEADERS: ' + JSON.stringify(res.headers));
- res.setEncoding('utf8');
- res.on('data', function (chunk) {
- console.log('BODY: ' + chunk);
- fs.writeFile('/tmp/google.txt', chunk, function (err) {
- if (err) throw err;
- console.log('It\'s saved!');
- });
- });
- });
- req.end();
- callback(null,"google");
- }
- ], function(error, arg) { console.log("ok");console.log(arg); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement