Skip to content

Commit

Permalink
Added support for <head>
Browse files Browse the repository at this point in the history
  • Loading branch information
mape committed Feb 5, 2011
1 parent bbf0111 commit 3058ba7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/test.js
Expand Up @@ -8,7 +8,7 @@ http.createServer(function (request, response) {
links += '<a href="/">Test - '+i+'</a>';
};
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('<html><body><div id="time">'+respondTime+'</div>'+links+'</body></html>\n');
response.end('<html><head><title>Page has '+linkCount+' links</title></head><body><div id="time">'+respondTime+'</div>'+links+'</body></html>\n');
}, respondTime);
}).listen(8486);

Expand All @@ -26,7 +26,7 @@ setTimeout(function() {
console.log(err);
return;
}
console.log('Server took '+$('#time').text()+'ms to respond, found '+$('a').length+' <a> @ '+new Date().toString());
console.log('Server took '+$('#time').text()+'ms to respond, found '+$('a').length+' <a> @ '+new Date().toString()+' with title "'+$('title').text()+'"');
}, {
'reqPerSec': 0.5
});
Expand Down
1 change: 1 addition & 0 deletions lib/scraper.js
Expand Up @@ -54,6 +54,7 @@ module.exports = function scrape(requestOptions, callback, fetchOptions) {
if (response && response.statusCode == 200) {
var window = jsdom.jsdom().createWindow();
jsdom.jQueryify(window, function(win, $) {
$('head').append($(body).find('head').html());
$('body').append($(body).find('body').html());
callback(null, $, requestOptions['uri']);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name" : "scraper",
"description" : "Easier web scraping using jQuery.",
"version" : "0.0.6",
"version" : "0.0.7",
"author" : "Mathias Pettersson <mape@mape.me>",
"engines" : ["node"],
"directories" : { "lib" : "./lib" },
Expand Down

0 comments on commit 3058ba7

Please sign in to comment.