https://github.com/ashi009/node-fast-html-parser It does the same thing, should be valuable to take a look and learn.