Reputation: 25
I tried this code
reaction=soup.find_all('span',class_='1n9k')
and the result is
[<span class="_1n9k" data-hover="tooltip" tabindex="-1"><a ajaxify="/ufi/reaction/profile/dialog/ft_ent_identifier=ZmVlZGJhY2s6MzgyODczMjYzMDg5MTQy&reaction_type=1&av=0" aria-label="좋아요 17" class="_1n9l"href="/ufi/reaction/profile/browser/ft_ent_identifier=ZmVlZGJhY2s6MzgyODczMjYzMDg5MTQy&av=0" rel="dialog" role="button" tabindex="0"><i class="sp_KIvjPBBBAwk sx_eaca68" role="img"></i></a></span>,<span class="_1n9k" data-hover="tooltip" tabindex="-1"><a ajaxify="/ufi/reaction/profile/dialog/?ft_ent_identifier=ZmVlZGJhY2s6MzgxNjk0Mjk2NTQwMzcy&reaction_type=1&av=0" aria-label="좋아요 55" class="_1n9l" href="/ufi/reaction/profile/browser/?ft_ent_identifier=ZmVlZGJhY2s6MzgxNjk0Mjk2NTQwMzcy&av=0" rel="dialog" role="button" tabindex="0"><i class="sp_KIvjPBBBAwk sx_eaca68" role="img"></i></a></span>,<span class="_1n9k" data-hover="tooltip" tabindex="-1"><a ajaxify="/ufi/reaction/profile/dialog/ft_ent_identifier=ZmVlZGJhY2s6MzgxNjk0Mjk2NTQwMzcy&reaction_type=2&av=0" aria-label="최고예요 3" class="_1n9l"href="/ufi/reaction/profile/browser/ft_ent_identifier=ZmVlZGJhY2s6MzgxNjk0Mjk2NTQwMzcy&av=0" rel="dialog" role="button" tabindex="-1"><i class="sp_KIvjPBBBAwk sx_b917e0" role="img"></i></a></span>]
I want to get the text in the attribute 'aria-label'. How could do this ? I can't use 'find'.
And I want to know this answer if i use 'select'.
Thanks.
Upvotes: 2
Views: 50
Reputation: 5531
Just loop through the list and print the aria-label
attribute of all span
tags, like this:
for span in reaction:
print(span.a['aria-label'])
Upvotes: 2