Parsing HTML using Python

前端 未结 7 645
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 00:35

I\'m looking for an HTML Parser module for Python that can help me get the tags in the form of Python lists/dictionaries/objects.

If I have a document of the form:

7条回答
  •  难免孤独
    2020-11-22 01:17

    I would use EHP

    https://github.com/iogf/ehp

    Here it is:

    from ehp import *
    
    doc = '''
    Heading
    
        
    Something here
    Something else
    ''' html = Html() dom = html.feed(doc) for ind in dom.find('div', ('class', 'container')): print ind.text()

    Output:

    Something here
    Something else
    

提交回复
热议问题