0
とPythonの構文解析は、私は上記のコードを修正は、私はBeautifulSoup library.IとPythonでHTMLを解析するために勉強していBeautifulSoup
import urllib
from BeautifulSoup import *
html_doc = """
<html><head><title>The Dormouse's story</title></head>
<body>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>,
<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;
and they lived at the bottom of a well.</p>
<p class="story">...</p>
"""
soup=BeautifulSoup(html_doc)
print soup.prettify()
print soup.title
print soup.title.name
print soup.title.string
print soup.title.parent.name
print soup.p
print soup.p['class']
print soup.a
print soup.find_all('a')
#for extracting URL's
for link in soup.find_all('a'):
print link.get('href')
print soup.get_text()
ヘルプを表示するエラーに出くわしました。私は、画像の下にはPythonの2を使用していた私は推測しますので、あなたは問題のエラーメッセージが表示されなかったエラーに
によってインポートされた
findAll()
代わりのfind_all()
とgetText()
の代わりget_text()
を必要とする現在の例では、シェル –
からエラーの詳細やスタックトレースを含めますあなたは間違っています。問題のフルエラーメッセージ(トレースバック)を常に表示してください。私たちは間違いなくコードを実行できます。 – furas
あなたは、コピー&ペーストする必要があり、エラーメッセージが - 誰もがメッセージをコピーして、答えやコメントでそれを使用することができますので、それはより便利することができます。 – furas