-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7.js
More file actions
18 lines (16 loc) · 634 Bytes
/
7.js
File metadata and controls
18 lines (16 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
Cliente HTTP
*
Fazer um HTTP GET request a um URL (unix stream)
A 'data' recebe o contudo html da pagina
The response object is a Node Stream object
You can treat Node Streams as objects that emit events, the three events that are of most interest are: "data", "error" and "end"
*/
var http = require('http') // http core module
function callback(response){ //assinatura da callback
response.setEncoding('utf8'); // conversao de HEX->UTF8
response.on("data", function handler(data){ //response.on escuta um evento, data e emitido quando os dados estao disponiveis
console.log(data)
})
}
http.get(process.argv[2], callback)