あなたのロジックと間違って何もありませんが、問題はIDある実際のidがjs_24
あるときにfjs_24
を持っている、間違っている:
emo = soup.find_all('a', {'id': 'js_24', 'class': '_27jf _3emk', 'data-hover':"tooltip"})
あなたが変更を加えたら、それが動作するのを見ることができます:
In [10]: from bs4 import BeautifulSoup
In [11]: soup = BeautifulSoup("""<a id="js_24" class="_27jf _3emk" data-hover="tooltip" aria-label="6 Wow" href="/ufi/reaction/profile/browser/?ft_ent_identifier=909182312524600&av=100011414120311" rel="ignore" role="button" tabindex="-1"></a>""","lxml")
In [12]: soup.find_all('a', {'id': 'fjs_24', 'class': '_27jf _3emk', 'data-hover':"tooltip"})
Out[12]: []
In [13]: soup.find_all('a', {'id': 'js_24', 'class': '_27jf _3emk', 'data-hover':"tooltip"})
Out[13]: [<a aria-label="6 Wow" class="_27jf _3emk" data-hover="tooltip" href="/ufi/reaction/profile/browser/?ft_ent_identifier=909182312524600&av=100011414120311" id="js_24" rel="ignore" role="button" tabindex="-1"></a>]
あなたがlxmlのがインストールされている場合、あなたはCSSセレクタを使用して多くのより速く、より簡潔にそれを行うことができます。
from lxml import html
tree = html.fromstring(""""<a id="js_24" class="_27jf _3emk" data-hover="tooltip" aria-label="6 Wow" href="/ufi/reaction/profile/browser/?ft_ent_identifier=909182312524600&av=100011414120311" rel="ignore" role="button" tabindex="-1"></a>""")
print(tree.cssselect("#js_24[class='_27jf _3emk'][data-hover='tooltip']"))
は、IDは一意ではありませんか? –
いいえ、あまり簡単ではありません;) –