為什么會(huì)報(bào)錯(cuò),BeautifulSoup下邊有紅線
from bs4 import BeautifulSoup
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 class="sister" id="link1">Elsie</a>,
<a class="sister" id="link2">Lacie</a> and
<a class="sister" id="link3">Tillie</a>;
and they lived at the bottom of a well.</p>
<p class="story">...</p>
"""
soup = BeautifulSoup(html_doc,'html.parser',fron_encoding='utf-8')
print '獲取所有的鏈接'
links = soup.find_all('a')
for link in links:
? ? print link.name,link['href'],link.get_text()
2018-02-25
如果你的插件安裝好了的話,估計(jì)你是自己寫了一個(gè)bs4.py的文件,所以沖突了,你應(yīng)該把你自己寫的文件改個(gè)別的名字。
2018-01-24
樓主,我研究了一個(gè)晚上,from bs4 import BeautifulSoup報(bào)錯(cuò)No module named 'bs4'問題,琢磨了一個(gè)方法。
首先,我使用的IDE是PyCharm Python版本3.6,在file選項(xiàng)中選擇settings選項(xiàng)點(diǎn)進(jìn)去
然后選擇Project Interpreter
雙擊pip點(diǎn)進(jìn)去
搜索ps4點(diǎn)擊 ? 然后點(diǎn)擊Install Package等會(huì)即可
應(yīng)該有用,但是我也是才學(xué)沒多久,方法也是在網(wǎng)上還是群里面看大佬們看出來的,希望對樓主有幫助。
2017-12-04
你看看你是不是把自己的某個(gè)包或者項(xiàng)目命名為bs4了
2017-10-07
你把from打成fron了
2017-09-14
Beautifulsoup沒安裝成功吧。檢查一下Python的環(huán)境變量
2017-09-06
試試用管理員權(quán)限運(yùn)行cmd