ehp.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:kivy_gosh 作者: mcroni 项目源码 文件源码
def find(self, name, *args):
        """
        It is used to find all objects that match name.

        Example 1:

        data = '<a><b></b><b></b></a>'
        html = Html()
        dom = html.feed(data)

        for ind in dom.find('b'):
            print ind

        It should print.

        <b ></b>
        <b ></b>

        Example 2.

        data = '<body> <p> alpha. </p> <p style="color:green"> beta.</p> </body>'
        html = Html()
        dom  = html.feed(data)

        for ind in dom.find('p', ('style', 'color:green')):
            print ind

        Output.


        <p style="color:green" > beta.</p>
        """

        for ind in self.sail():
            if ind.name == name:
                for key, value in args:
                    if ind.attr[key] != value:
                        break
                else:
                    yield(ind)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号