Created
June 25, 2011 14:20
-
-
Save fnando/1046536 to your computer and use it in GitHub Desktop.
Scraping using Node.js and jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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