Improved HTML parser

Hi @PaulKinlan,
Could you review my change?
It's improving the metadata generation. It's using an HTML parser instead of using regexp.
It will also detect the encoding of the HTML page to improve unicode compatibility.
Thanks!