from bs4 import BeautifulSoup
import requests
import lxml
url = 'https://en.wikipedia.org/wiki/Berlin_Wall/'
cream = requests.get(url).content
soup= BeautifulSoup(cream, 'lxml')
table = soup.find('table', {'class' : 'infobox vcard'})
type(table)
table_rows = table.find_all('tr')
for tr in table_rows:
print(td.text)
我正在使用python3。我试图从维基百科页面中删除信息框,但继续得到AttributeError:'NoneType'对象没有属性'find_all'。任何人都知道这个问题是什么?
你的脚本中有几个简单的错误:
/
)。
url = 'https://en.wikipedia.org/wiki/Berlin_Wall'
td
在您的循环中不存在,因此将其更改为tr
:print(tr.text)