Issue
I'd like to return just the second line below. So I'd like to select based on tags td
and span
and classes right
and cap
.
<td class="center small"><span class="cap" title="">WR</span></td>
<td class="right"><span class="cap">$13,000,000</span></td>
I've tried the following, because I need to select the exact match of cap
and not other classes like cap info
:
salaries = soup.find_all(lambda tag: tag.name == 'span' and tag.get('class') == ['cap'])
but it still returns the two lines below, because (I think) the td
tags and corresponding classes still differ (as seen above in the original html lines):
<span class="cap" title="">WR</span>, <span class="cap">$13,000,000</span>,
Solution
salaries = soup.find_all(lambda tag: tag.name == 'span' and tag.get('class') == ['cap'] and not tag.get('title') == '')
Answered By - ElphiusMostafa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.