Node.js Сохранение HTML-ответа GET-запроса

Очевидно, я немного новичок в Javascript, чем хотел бы признать. Я пытаюсь вытащить веб-страницу с помощью Node.js и сохранить содержимое как переменную, поэтому я могу анализировать ее, как мне хочется.

В Python я бы сделал так:

from bs4 import BeautifulSoup # for parsing
import urllib

text = urllib.urlopen("http://www.myawesomepage.com/").read()

parse_my_awesome_html(text)

Как бы я сделал это в Node? Я дошел до:

var request = require("request");
request("http://www.myawesomepage.com/", function (error, response, body) {
    /*
     Something here that lets me access the text
     outside of the closure

     This doesn't work:
     this.text = body;
    */ 
})
5
задан jdotjdot 7 July 2012 в 00:31
поделиться