2016-11-19 9 views
0

learingテストプログラムの作成中にTypeErrorが発生しました。ここでTypeError:__init __()missing 2つの必須の位置引数: 'selfClosingTags'と 'isHTML'

コードです:

from bs4 import BeautifulSoup 

newurl = 'http://susumr.cc/' 
soup = BeautifulSoup(newurl,'lxml') 
print(soup.text) 

私はこのエラーを得た:私もインストール

TypeError: __init__() missing 2 required positional arguments: 'selfClosingTags' and 'isHTML' 

サードパーティのライブラリを、私はこれがどのように知っている、と数日間混乱し

はありません

答えて

0

urlではなく、BeautifulSoupのコンストラクタにHTML文字列を渡す必要があります。

import urllib 

from bs4 import BeautifulSoup 

newurl = 'http://susumr.cc/' 
content = urllib.urlopen(newurl).read() # Retrive url content 
soup = BeautifulSoup(content, 'lxml') # pass the content to `BeautifulSoup` constructor 
print(soup.text) 
関連する問題