h1 = soup.find('a', {'class': 'lien-jv topic-title'})['title']
print (h1)
タイトルタグにある値をsoup.find関数で取得するのに問題はありませんでした。 しかし、私は解析しているページにそのような複数のタグがあるので、私はsoup.find_all関数を使用する必要があり、それは動作していません。このコードPython&BeautifulSoup:soup.find_allの問題
h1 = soup.find_all('a', {'class': 'lien-jv topic-title'})['title']
print (h1)
で
私はこのエラーに助けを
Traceback (most recent call last):
File "<tmp 1>", line 8, in <module>
h1 = soup.find_all('a', {'class': 'lien-jv topic-title'})['title']
TypeError: list indices must be integers, not str
感謝していました。
は '、あなたはすべてのタグのタイトルが必要なのでしょうか? – PRMoureu
はい、私はすべてのタグのタイトルが必要です! – Diamonds