Skip to content

Instantly share code, notes, and snippets.

@fnando
Created June 25, 2011 14:20
Show Gist options
  • Save fnando/1046536 to your computer and use it in GitHub Desktop.
Save fnando/1046536 to your computer and use it in GitHub Desktop.
Scraping using Node.js and jQuery
var url = require("url")
, http = require("http")
, $ = require("jquery")
, uri = url.parse("http://simplesideias.com.br")
, html = ""
;
http.request(uri, function(response){
response.on("data", function(data){
html += data;
});
response.on("end", function(){
$("a.title", html).each(function(){
console.log($(this).text());
console.log(this.href);
console.log("");
});
$("meta", html).each(function(){
console.log("= name: ", this.name);
console.log("= rel: ", this.rel);
console.log("= content: ", this.content);
console.log("=== ");
});
});
}).end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment