{"_id":"htmlparser","_rev":"57861","name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","dist-tags":{"latest":"1.7.7"},"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"time":{"modified":"2021-06-03T10:17:40.000Z","created":"2012-01-16T19:01:57.081Z","1.7.7":"2013-12-20T01:16:25.259Z","1.7.6":"2012-04-12T18:13:04.531Z","1.7.5":"2012-04-02T00:28:21.279Z","1.7.4":"2012-01-16T19:01:57.081Z","1.6.2":"2012-01-16T19:01:57.081Z","1.7.0":"2012-01-16T19:01:57.081Z","1.7.1":"2012-01-16T19:01:57.081Z","1.7.2":"2012-01-16T19:01:57.081Z","1.7.3":"2012-01-16T19:01:57.081Z"},"users":{"fgribreau":true,"cparker15":true,"huoshaolin":true,"doliveira":true,"jprempeh":true,"toshimichimiki":true,"uniquerockrz":true,"xek":true,"fassetar":true,"jeremypage":true,"joshmili":true,"luckyulin":true,"gindis":true,"pandao":true,"thomasjang":true,"juangotama":true,"rubiadias":true,"heineiuo":true,"kaikaiiiiiii":true,"tkothe":true,"kael":true,"moueza":true,"jackstraw":true,"xyyjk":true,"kistoryg":true,"ukuli":true,"chaoliu":true,"jorycn":true,"wozhizui":true,"shuoshubao":true,"pftom":true,"rioli":true},"author":{"name":"Chris Winberry","email":"chris@winberry.net"},"repository":{"type":"git","url":"https://github.com/tautologistics/node-htmlparser"},"versions":{"1.7.7":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.7","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"https://github.com/tautologistics/node-htmlparser"},"keywords":["html","xml","rss","parser"],"directories":{"lib":"./lib/"},"main":"./lib/htmlparser","homepage":"http://github.com/tautologistics/node-htmlparser","bugs":{"url":"http://github.com/tautologistics/node-htmlparser/issues"},"engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.7.7","_from":".","dist":{"shasum":"19e7b3997ff6fbac99ae5a7d2766489efe7e2d0e","size":26574,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.7.tgz"},"_npmVersion":"1.3.14","_npmUser":{"name":"tautologistics","email":"chris@winberry.net"},"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"publish_time":1387502185259,"_hasShrinkwrap":false,"_cnpm_publish_time":1387502185259},"1.7.6":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.6","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"keywords":["html","xml","rss","parser"],"directories":{"lib":"./lib/"},"main":"./lib/htmlparser","homepage":"http://github.com/tautologistics/node-htmlparser","bugs":{"email":"chris@winberry.net","url":"http://github.com/tautologistics/node-htmlparser/issues"},"engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_npmUser":{"name":"tautologistics","email":"chris@winberry.net"},"_id":"htmlparser@1.7.6","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.10","_defaultsLoaded":true,"dist":{"shasum":"6a263c7ee5930f3e5c56fa564011f99e49f80d34","size":243574,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.6.tgz"},"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"publish_time":1334254384531,"_hasShrinkwrap":false,"_cnpm_publish_time":1334254384531},"1.7.5":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.5","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"keywords":["html","xml","rss","parser"],"directories":{"lib":"./lib/"},"main":"./lib/htmlparser","homepage":"http://github.com/tautologistics/node-htmlparser","bugs":{"email":"chris@winberry.net","url":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd","win32","openbsd"],"engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_npmUser":{"name":"tautologistics","email":"chris@winberry.net"},"_id":"htmlparser@1.7.5","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.10","_defaultsLoaded":true,"dist":{"shasum":"5c9df08be5d6fc63c0ab7a97e4c03d58de76857a","size":223435,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.5.tgz"},"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"publish_time":1333326501279,"_hasShrinkwrap":false,"_cnpm_publish_time":1333326501279},"1.7.4":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.4","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"keywords":["html","xml","rss","parser"],"directories":{"lib":"./lib/"},"main":"./lib/htmlparser","homepage":"http://github.com/tautologistics/node-htmlparser","bugs":{"email":"chris@winberry.net","url":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd","win32"],"engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_npmUser":{"name":"tautologistics","email":"chris@winberry.net"},"_id":"htmlparser@1.7.4","dependencies":{},"devDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-beta-4","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"344467cfe8ed1310d77397ea00a200db7e2e8922","size":25278,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.4.tgz"},"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"publish_time":1326740517081,"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081},"1.6.2":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.6.2","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"bugs":{"mail":"chris@winberry.net","web":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd"],"directories":{"lib":"./lib/"},"main":"./lib/node-htmlparser","engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.6.2","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"shasum":"23acb8d57ae0c042da7aaf5b1e8e39916c900e46","size":22163,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.6.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.6.2.tgz"},"publish_time":1326740517081,"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081},"1.7.0":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.0","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"bugs":{"mail":"chris@winberry.net","web":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd"],"directories":{"lib":"./lib/"},"main":"./lib/node-htmlparser","engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.7.0","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.0-pre","dist":{"shasum":"53a419f2859ba870028ac9c7211dd655b80425cd","size":220910,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.0.tgz"},"publish_time":1326740517081,"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081},"1.7.1":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.1","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"bugs":{"mail":"chris@winberry.net","web":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd"],"directories":{"lib":"./lib/"},"main":"./lib/node-htmlparser","engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.7.1","_nodeSupported":true,"_npmVersion":"0.2.8-1","_nodeVersion":"v0.3.0-pre","dist":{"shasum":"9da09d497f15507bf8913a4f239ffd8af03b4ef9","size":223417,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.1.tgz"},"publish_time":1326740517081,"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081},"1.7.2":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.2","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"bugs":{"mail":"chris@winberry.net","web":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd"],"directories":{"lib":"./lib/"},"main":"./lib/node-htmlparser","engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.7.2","_nodeSupported":true,"_npmVersion":"0.2.8-1","_nodeVersion":"v0.3.0-pre","dist":{"shasum":"1573734a5e39be9f28fadc5923f82c1d6035d236","size":223232,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.2.tgz"},"publish_time":1326740517081,"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081},"1.7.3":{"name":"htmlparser","description":"Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers","version":"1.7.3","author":{"name":"Chris Winberry","email":"chris@winberry.net"},"contributors":[],"repository":{"type":"git","url":"git://github.com/tautologistics/node-htmlparser.git"},"bugs":{"email":"chris@winberry.net","url":"http://github.com/tautologistics/node-htmlparser/issues"},"os":["linux","darwin","freebsd","win32"],"directories":{"lib":"./lib/"},"main":"./lib/htmlparser","engines":{"node":">=0.1.33"},"licenses":[{"type":"MIT","url":"http://github.com/tautologistics/node-htmlparser/raw/master/LICENSE"}],"_id":"htmlparser@1.7.3","_nodeSupported":true,"_npmVersion":"0.2.11","_nodeVersion":"v0.3.1","dist":{"shasum":"67a98b21aeabbf2a8703bbdd4debe30f80f33217","size":223371,"noattachment":false,"key":"/htmlparser/-/htmlparser-1.7.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/htmlparser/download/htmlparser-1.7.3.tgz"},"publish_time":1326740517081,"maintainers":[{"name":"tautologistics","email":"chris@winberry.net"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1326740517081}},"readme":"#NodeHtmlParser\nA forgiving HTML/XML/RSS parser written in JS for both the browser and NodeJS (yes, despite the name it works just fine in any modern browser). The parser can handle streams (chunked data) and supports custom handlers for writing custom DOMs/output.\n\n##Installing\n\n\tnpm install htmlparser\n\n##Running Tests\n\n###Run tests under node:\n\tnode runtests.js\n\n###Run tests in browser:\nView runtests.html in any browser\n\n##Usage In Node\n\n```javascript\nvar htmlparser = require(\"htmlparser\");\nvar rawHtml = \"Xyz <script language= javascript>var foo = '<<bar>>';< /  script><!--<!-- Waah! -- -->\";\nvar handler = new htmlparser.DefaultHandler(function (error, dom) {\n\tif (error)\n\t\t[...do something for errors...]\n\telse\n\t\t[...parsing done, do something...]\n});\nvar parser = new htmlparser.Parser(handler);\nparser.parseComplete(rawHtml);\nsys.puts(sys.inspect(handler.dom, false, null));\n```\n\n##Usage In Browser\n\n```javascript\nvar handler = new Tautologistics.NodeHtmlParser.DefaultHandler(function (error, dom) {\n\tif (error)\n\t\t[...do something for errors...]\n\telse\n\t\t[...parsing done, do something...]\n});\nvar parser = new Tautologistics.NodeHtmlParser.Parser(handler);\nparser.parseComplete(document.body.innerHTML);\nalert(JSON.stringify(handler.dom, null, 2));\n```\n\n##Example output\n\n```javascript\n[ { raw: 'Xyz ', data: 'Xyz ', type: 'text' }\n  , { raw: 'script language= javascript'\n  , data: 'script language= javascript'\n  , type: 'script'\n  , name: 'script'\n  , attribs: { language: 'javascript' }\n  , children: \n     [ { raw: 'var foo = \\'<bar>\\';<'\n       , data: 'var foo = \\'<bar>\\';<'\n       , type: 'text'\n       }\n     ]\n  }\n, { raw: '<!-- Waah! -- '\n  , data: '<!-- Waah! -- '\n  , type: 'comment'\n  }\n]\n```\n\n##Streaming To Parser\n\n```javascript\nwhile (...) {\n\t...\n\tparser.parseChunk(chunk);\n}\nparser.done();\t\n```\n\n##Parsing RSS/Atom Feeds\n\n```javascript\nnew htmlparser.RssHandler(function (error, dom) {\n\t...\n});\n```\n\n##DefaultHandler Options\n\n###Usage\n\n```javascript\nvar handler = new htmlparser.DefaultHandler(\n\t  function (error) { ... }\n\t, { verbose: false, ignoreWhitespace: true }\n\t);\n```\n\n###Option: ignoreWhitespace\nIndicates whether the DOM should exclude text nodes that consists solely of whitespace. The default value is \"false\".\n\n####Example: true\n\nThe following HTML:\n\n```html\n<font>\n\t<br>this is the text\n<font>\n```\n\nbecomes:\n\n```javascript\n[ { raw: 'font'\n  , data: 'font'\n  , type: 'tag'\n  , name: 'font'\n  , children: \n     [ { raw: 'br', data: 'br', type: 'tag', name: 'br' }\n     , { raw: 'this is the text\\n'\n       , data: 'this is the text\\n'\n       , type: 'text'\n       }\n     , { raw: 'font', data: 'font', type: 'tag', name: 'font' }\n     ]\n  }\n]\n```\n\n####Example: false\n\nThe following HTML:\n\n```html\n<font>\n\t<br>this is the text\n<font>\n```\n\nbecomes:\n\n```javascript\n[ { raw: 'font'\n  , data: 'font'\n  , type: 'tag'\n  , name: 'font'\n  , children: \n     [ { raw: '\\n\\t', data: '\\n\\t', type: 'text' }\n     , { raw: 'br', data: 'br', type: 'tag', name: 'br' }\n     , { raw: 'this is the text\\n'\n       , data: 'this is the text\\n'\n       , type: 'text'\n       }\n     , { raw: 'font', data: 'font', type: 'tag', name: 'font' }\n     ]\n  }\n]\n```\n\n###Option: verbose\nIndicates whether to include extra information on each node in the DOM. This information consists of the \"raw\" attribute (original, unparsed text found between \"<\" and \">\") and the \"data\" attribute on \"tag\", \"script\", and \"comment\" nodes. The default value is \"true\". \n\n####Example: true\nThe following HTML:\n\n```html\n<a href=\"test.html\">xxx</a>\n```\n\nbecomes:\n\n```javascript\n[ { raw: 'a href=\"test.html\"'\n  , data: 'a href=\"test.html\"'\n  , type: 'tag'\n  , name: 'a'\n  , attribs: { href: 'test.html' }\n  , children: [ { raw: 'xxx', data: 'xxx', type: 'text' } ]\n  }\n]\n```\n\n####Example: false\nThe following HTML:\n\n```javascript\n<a href=\"test.html\">xxx</a>\n```\n\nbecomes:\n\n```javascript\n[ { type: 'tag'\n  , name: 'a'\n  , attribs: { href: 'test.html' }\n  , children: [ { data: 'xxx', type: 'text' } ]\n  }\n]\n```\n\n###Option: enforceEmptyTags\nIndicates whether the DOM should prevent children on tags marked as empty in the HTML spec. Typically this should be set to \"true\" HTML parsing and \"false\" for XML parsing. The default value is \"true\".\n\n####Example: true\nThe following HTML:\n\n```html\n<link>text</link>\n```\n\nbecomes:\n\n```javascript\n[ { raw: 'link', data: 'link', type: 'tag', name: 'link' }\n, { raw: 'text', data: 'text', type: 'text' }\n]\n```\n\n####Example: false\nThe following HTML:\n\n```html\n<link>text</link>\n```\n\nbecomes:\n\n```javascript\n[ { raw: 'link'\n  , data: 'link'\n  , type: 'tag'\n  , name: 'link'\n  , children: [ { raw: 'text', data: 'text', type: 'text' } ]\n  }\n]\n```\n\n##DomUtils\n\n###TBD (see utils_example.js for now)\n\n##Related Projects\n\nLooking for CSS selectors to search the DOM? Try Node-SoupSelect, a port of SoupSelect to NodeJS: http://github.com/harryf/node-soupselect\n\nThere's also a port of hpricot to NodeJS that uses HtmlParser for HTML parsing: http://github.com/silentrob/Apricot\n\n","_attachments":{},"homepage":"http://github.com/tautologistics/node-htmlparser","bugs":{"url":"http://github.com/tautologistics/node-htmlparser/issues"}}