Comparing version 0.2.2 to 0.3.0
@@ -0,1 +1,9 @@ | ||
0.3.0 / 2011-11-19 | ||
================= | ||
* Now using htmlparser2 for parsing (2x speed increase, cleaner, actively developed) | ||
* Added benchmark directory for future speed tests | ||
* $("...").dom() was funky, so it was removed in favor of $("...").get(). $.dom() still works the same. | ||
* $.root now correctly static across all instances of $ | ||
* Added a screencast | ||
0.2.2 / 2011-11-9 | ||
@@ -2,0 +10,0 @@ ================= |
(function() { | ||
var $, after, append, before, dom, empty, html, parser, prepend, remove, removeChild, text, _; | ||
var $, after, append, before, empty, html, parser, prepend, remove, removeChild, text, _; | ||
var __slice = Array.prototype.slice; | ||
@@ -20,3 +20,3 @@ _ = require('underscore'); | ||
elem = elems[_i]; | ||
dom.push($(elem).dom()); | ||
dom = dom.concat($(elem).get()); | ||
} | ||
@@ -40,3 +40,3 @@ this.each(function() { | ||
elem = elems[_i]; | ||
dom.push($(elem).dom()); | ||
dom = dom.concat($(elem).get()); | ||
} | ||
@@ -55,8 +55,8 @@ this.each(function() { | ||
after = exports.after = function() { | ||
var doms, elem, elems, _i, _len; | ||
var dom, elem, elems, _i, _len; | ||
elems = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
doms = []; | ||
dom = []; | ||
for (_i = 0, _len = elems.length; _i < _len; _i++) { | ||
elem = elems[_i]; | ||
doms.push($(elem).dom()); | ||
dom = dom.concat($(elem).get()); | ||
} | ||
@@ -68,3 +68,3 @@ this.each(function() { | ||
if (pos >= 0) { | ||
siblings.splice.apply(siblings, [pos + 1, 0].concat(doms)); | ||
siblings.splice.apply(siblings, [pos + 1, 0].concat(dom)); | ||
} | ||
@@ -76,8 +76,8 @@ return $.updateDOM(siblings, this.parent); | ||
before = exports.before = function() { | ||
var doms, elem, elems, _i, _len; | ||
var dom, elem, elems, _i, _len; | ||
elems = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
doms = []; | ||
dom = []; | ||
for (_i = 0, _len = elems.length; _i < _len; _i++) { | ||
elem = elems[_i]; | ||
doms.push($(elem).dom()); | ||
dom = dom.concat($(elem).get()); | ||
} | ||
@@ -89,5 +89,5 @@ this.each(function() { | ||
if (pos >= 0) { | ||
siblings.splice.apply(siblings, [pos, 0].concat(doms)); | ||
siblings.splice.apply(siblings, [pos, 0].concat(dom)); | ||
} | ||
return $.updateDOM(siblings, this.parent); | ||
return this.parent = $.updateDOM(siblings, this.parent); | ||
}); | ||
@@ -115,9 +115,2 @@ return this; | ||
}; | ||
dom = exports.dom = function(domObject) { | ||
if (domObject === void 0) { | ||
if (this[0] && $.isTag(this[0])) { | ||
return $.dom(this[0]); | ||
} | ||
} | ||
}; | ||
html = exports.html = function(htmlString) { | ||
@@ -124,0 +117,0 @@ var htmlElement; |
@@ -53,2 +53,3 @@ (function() { | ||
parent.children = arr; | ||
return parent; | ||
}; | ||
@@ -55,0 +56,0 @@ type = exports.type = function(obj) { |
@@ -16,3 +16,3 @@ (function() { | ||
cheerio.fn = cheerio.prototype = { | ||
cheerio: "0.2.2", | ||
cheerio: "0.3.0", | ||
constructor: cheerio, | ||
@@ -25,3 +25,5 @@ init: function(selector, context, root) { | ||
if (root) { | ||
this.root = root; | ||
cheerio.extend({ | ||
'root': root | ||
}); | ||
if (_.isString(context)) { | ||
@@ -61,4 +63,3 @@ selector = "" + context + " " + selector; | ||
splice: [].splice, | ||
length: 0, | ||
root: void 0 | ||
length: 0 | ||
}; | ||
@@ -69,2 +70,5 @@ cheerio.fn.init.prototype = cheerio.fn; | ||
}; | ||
cheerio.extend({ | ||
root: void 0 | ||
}); | ||
return cheerio; | ||
@@ -71,0 +75,0 @@ })(); |
(function() { | ||
var connectDOM, fs, htmlparser, parse; | ||
htmlparser = require("htmlparser"); | ||
htmlparser = require("htmlparser2"); | ||
fs = require("fs"); | ||
@@ -5,0 +5,0 @@ parse = exports.parse = function(content) { |
@@ -19,3 +19,4 @@ (function() { | ||
param: 1, | ||
embed: 1 | ||
embed: 1, | ||
include: 1 | ||
}; | ||
@@ -22,0 +23,0 @@ tagType = { |
@@ -6,3 +6,3 @@ { | ||
"keywords": ["htmlparser", "jquery", "selector", "scraper"], | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"repository": { | ||
@@ -18,3 +18,3 @@ "type": "git", | ||
"soupselect" : "0.2.x", | ||
"htmlparser" : "1.x", | ||
"htmlparser2" : "1.x", | ||
"underscore" : "1.x" | ||
@@ -26,3 +26,4 @@ }, | ||
"diff_match_patch" : "0.1.x", | ||
"should" : "0.x" | ||
"should" : "0.x", | ||
"request" : "2.x" | ||
}, | ||
@@ -29,0 +30,0 @@ "scripts": { |
@@ -131,3 +131,3 @@ # cheerio | ||
#### addClass( className ) | ||
#### .addClass( className ) | ||
Adds class(es) to all of the matched elements. Also accepts a `function` like jQuery. | ||
@@ -143,3 +143,3 @@ | ||
#### removeClass( [className] ) | ||
#### .removeClass( [className] ) | ||
Removes one or more space-separated classes from the selected elements. If no `className` is defined, all classes will be removed. Also accepts a `function` like jQuery. | ||
@@ -188,3 +188,3 @@ | ||
#### .children() | ||
#### .children( selector ) | ||
Gets the children of the first selected element. | ||
@@ -194,2 +194,5 @@ | ||
=> 3 | ||
$('#fruits').children('.pear').text() | ||
=> Pear | ||
@@ -377,2 +380,8 @@ #### .each( function(index, element) ) | ||
## Screencasts | ||
http://vimeo.com/31950192 | ||
> This video tutorial is a follow-up to Nettut's "How to Scrape Web Pages with Node.js and jQuery", using cheerio instead of JSDOM + jQuery. This video shows how easy it is to use cheerio and how much faster cheerio is than JSDOM + jQuery. | ||
## Testing | ||
@@ -379,0 +388,0 @@ |
Sorry, the diff of this file is not supported yet
47690
18
428
5
934
+ Addedhtmlparser2@1.x
+ Addedhtmlparser2@1.5.0(transitive)
- Removedhtmlparser@1.x