我是Python編程新手我剛剛安裝了Python(版本3.5.2),我正在使用Geany編輯器來編寫和執行我的腳本。使用BeautifulSoup從網頁中提取文本
我只是嘗試這個簡單的腳本,但它失敗:
from bs4 import BeautifulSoup
import urllib
r = urllib.urlopen('http://www.aflcio.org/Legislation-and-Politics/Legislative-Alerts').read()
soup = BeautifulSoup(r)
錯誤:
Traceback (most recent call last): File "soup.py", line 1, in <module> from bs4 import BeautifulSoup ImportError: No module named 'bs4'
我一直在使用pip install bs4
安裝BeautifulSoup,我也得到了成功輸出「成功安裝bs4-0.0。 1「
我明白這是一個簡單的問題,但任何幫助,將不勝感激!
你有沒有做'pip install beautifulsoup4'? –
錯誤說,我引用:「導入錯誤:沒有名爲'bs4'的模塊」。這意味着沒有名爲'bs4'的模塊。嘗試:'pip安裝beautifulsoup4'並查看輸出結果。試試'哪個python'和哪個pip來檢查你使用的pip和python。 – allcaps
我試過bs4和beautifulsoup4。 – Dinesh