Issue
I am trying to find <a>
tag with itemprop
attribute being url
. So far the only approach i found is to use a lambda:
soup.find(lambda a : a.name=='a' and a.has_attr('itemprop') and a['itemprop']=='url')
But somehow i cannot believe that this is the best approach. Is there something simpler?
Solution
You can pass a dict to find.
soup.find("a", {"itemprop" : "url"})
Alternatively, use a CSS selector.
soup.select_one("a[itemprop='url']")
Answered By - Unmitigated
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.