Issue
With BS4, how can I search for all tags that have a given attribute data-path
? I.e, how can I search for an attribute without specifying an element (as I don't want to assume specific elements) or an attribute value?
This returns nothing:
parser.find_all(attr='data-path')
Solution
You can use a filter function:
parser.find_all(lambda tag: tag is not None and tag.has_attr("data-path"))
Answered By - joni
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.