Test if an attribute is present in a tag in BeautifulSoup

后端 未结 6 814
天涯浪人
天涯浪人 2020-12-07 22:01

I would like to get all the

6条回答
  •  青春惊慌失措
    2020-12-07 22:43

    If i understand well, you just want all the script tags, and then check for some attributes in them?

    scriptTags = outputDoc.findAll('script')
    for script in scriptTags:
        if script.has_attr('some_attribute'):
            do_something()        
    

提交回复
热议问题