Skip to content

Instantly share code, notes, and snippets.

Created March 16, 2010 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/333511 to your computer and use it in GitHub Desktop.
Save anonymous/333511 to your computer and use it in GitHub Desktop.
var fs = require("fs");
var http = require("http");
var client = http.createClient(80, "google.com");
var request = client.request("GET", "/", {"host": "google.com"});
var file = fs.createWriteStream("google.html",
{ flags: "w",
mode: 0644 });
request.addListener("response", function(response) {
response.addListener("data", function(chunk) {
file.write(chunk);
});
response.addListener("end", function() {
file.close();
});
});
request.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment