NameError: name 'beautifulsoup' is not define
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-2d9df5aef3d8> in <module>()
----> 1 soup = beautifulsoup(html_paser)
2 header = soup.select ('h1')
3 print(header)
NameError: name 'beautifulsoup' is not defined
奇怪咧
我上網看是說 沒有
from bs4 import BeautifulSoup
但我有阿
為啥有問題
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 39.8.13.109
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1545027179.A.8CE.html
推
12/17 14:13,
7年前
, 1F
12/17 14:13, 1F
→
12/17 14:14,
7年前
, 2F
12/17 14:14, 2F
→
12/17 14:14,
7年前
, 3F
12/17 14:14, 3F
→
12/17 14:14,
7年前
, 4F
12/17 14:14, 4F
→
12/17 14:14,
7年前
, 5F
12/17 14:14, 5F
→
12/17 14:14,
7年前
, 6F
12/17 14:14, 6F
→
12/17 14:16,
7年前
, 7F
12/17 14:16, 7F
→
12/17 14:16,
7年前
, 8F
12/17 14:16, 8F
→
12/17 14:19,
7年前
, 9F
12/17 14:19, 9F
推
12/17 14:19,
7年前
, 10F
12/17 14:19, 10F
from bs4 import BeautifulSoup
html_sample = ' \
<html> \
<body> \
<h1 id="title">Hello World</h1> \
<a href="#" class="link">This is link1</a> \
<a href="# link2" class="link">This is link2</a> \
</body> \
</html>'
soup = BeautifulSoup(html_sample, 'html.parser')
print(type(soup))
print(soup.text)
soup = beautifulsoup(html_paser, 'html.paser')
header = soup.select ('h1')
print(header)
哪個要大小寫==
※ 編輯: oz5566 (39.8.13.109), 12/17/2018 14:20:28
推
12/17 14:22,
7年前
, 11F
12/17 14:22, 11F
→
12/17 14:22,
7年前
, 12F
12/17 14:22, 12F
→
12/17 14:25,
7年前
, 13F
12/17 14:25, 13F
推
12/17 14:41,
7年前
, 14F
12/17 14:41, 14F
討論串 (同標題文章)