In Node.js / Express, how do I "download" a page and gets its HTML?

Inside the code, I want to download "" and store it in a string. I know how to do that in urllib in python. But how do you do it in Node.JS + Express?


Using node.js you can just use the http.request method

This method is built into node you just need to require http.

If you just want to do a GET, then you can use http.get

var options = {
  host: '',
  port: 80,
  path: '/index.html'

http.get(options, function(res) {
  console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
  console.log("Got error: " + e.message);

(Example from node.js docs)

You could also use mikeal's request module

var util = require("util"),
    http = require("http");

var options = {
    host: "",
    port: 80,
    path: "/"

var content = "";   

var req = http.request(options, function(res) {
    res.on("data", function (chunk) {
        content += chunk;

    res.on("end", function () {


Simple short and efficient code :)
var request = require("request");

    { uri: "" },
    function(error, response, body) {

doc link :

Need Your Help

How to detect a tap gesture in subviews

objective-c ios uiview touch uitapgesturerecognizer

Quick question: how do i detect if a tap gesture recognizer is within a subview of the view it is added to? Eg. if i click on an object such as a square that has been added as a subview to a backgr...

How do I change the style of the cursor with JQuery?

javascript jquery cursor mouse

I want to change the style of the cursor as if it were going over a link. How do I do this?