這段代碼哪里錯了,為什么運行不了提示出錯?
#coding:utf-8 from?BeautifulSoup?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?>Elsie</a>, <a?>Lacie</a>?and <a?>Tillie</a>; and?they?lived?at?the?bottom?of?a?well.</p> <p?class="story">...</p> """ soup?=?BeautifulSoup(html_doc,?'html.parser',from_encoding?=?'utf-8') print?'獲取所有的連接' links?=?soup.find_all('a') for?link?in?links: ????print?link.name,link['href'],link.get_text()
沒法運行 = =
錯誤如下:
Traceback (most recent call last):
? File "F:/final/hello.py", line 18, in <module>
? ? soup = BeautifulSoup(html_doc, 'html.parser',from_encoding = 'utf-8')
? File "F:\final\python27\BeautifulSoup.py", line 1522, in __init__
? ? BeautifulStoneSoup.__init__(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'from_encoding'
2017-04-04
TypeError: __init__() got an unexpected keyword argument 'from_encoding'
構(gòu)造函數(shù)參數(shù)錯誤
我猜你用的BeautifulSoup是BeautifulSoup3版本,3版本這個位置參數(shù)是:fromEncoding,你換這個參數(shù)名試一試
2022-03-26
雖然我不是處女座,但是強迫癥表示傷不起元素的實際高度(盒子的高度)=上邊界 上邊框 上填充 內(nèi)容高度 下填充 下邊框 下邊界。
2017-04-04
把“from?BeautifulSoup?import?BeautifulSoup”這句話里的第一個“BeautifulSoup”改成“bs4”
2017-04-04
BeautifulSoup import BeautifulSoup 改成?bs4 import BeautifulSoup