Python development _ HTMLParser_html document Parsing

Source: Internet
Author: User

Class, many methods are defined, but many methods are not implemented, which requires us to inheritClass, implement some methods by yourself, such as: # Overridable -- handle start tag def handle_starttag (self, tag, attrs): pass # Overridable -- handle end tag def handle_endtag (self, tag ): pass # Overridable -- handle character reference def handle_charref (self, name): pass # Overridable -- handle entity reference def handle_entityref (self, name ): pass # Overridable -- handle data def handle_data (self, data): pass # Overridable -- handle comment def handle_comment (self, data): pass # Overridable -- handle declaration def handle_decl (self, decl): pass # Overridable -- handle processing instruction def handle_pi (self, data): pass

Below is my demo

:

Python 3.3.2 (v3.3.2: d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32, >>> ================================== RESTART ======== ==========================================>>><! Doctype html public> 

            html.parser                                           HTML_FILE =  HTML_STR =                             (              (              (              (              (             parser = MyHTMLParser(strict =               content =               (         with open(path,               line                  content +=                            (                          HTML_FILE =                HTML_STR =        (     ( * 50     ==      main()

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.