1
BeautifulSoupを使用して、1つのhtml表の最初と2番目の太字見出しの後の次の行の列1と列3のテキストを抽出しようとしています。太字のテキストはクラスまたはIDを持たず、その上下の行と同じレベルにあります。私はnext_siblingを使うべきだと思いますが、それをどうやってやっていくのかが分かりません。HTML表の各太字見出しの後に行の特定の列を抽出するBeautifulSoup
あなたはここで、テーブルのHTMLを見つけることができます:https://github.com/Tokaalmighty/topmover_table_html/blob/master/html
は、ここに私のロジックです:
soup=bs(f1,'html.parser')
topmovers=soup.find('table',{'class':'topmovers'})
bold=topmovers.find_all('b')
gainer=bold[0]
gainer_name=bold.find('tr').next_sibling
gcol1=gainer_name[0]
gcol3=gainer_name[2]
loser=bold[1]
loser_name=bold.find('tr').next_sibling
lcol1=loser_name[0]
lcol3=loser_name[2]
print(gcol1,gcol3,lcol1,lcol3)
あなたはhtml構造を共有できますか? – eLRuLL