一般情况下,对Web抓取和编码来说都是新手.对于更有经验的人来说,这可能是一个简单的问题.也许不是...它是这样的:
试图通过网络从维基百科上刮一张桌子.我已经在html中找到了表,并将该信息添加到我的代码中.但是,当我运行它时,返回的是‘None’,而不是确认表已被正确定位.
from bs4 import BeautifulSoup
from urllib.request import urlopen
url = 'https://en.wikipedia.org/wiki/List_of_songs_recorded_by_the_Beatles'
html = urlopen(url)
soup = BeautifulSoup(html, 'html.parser')
table = soup.find('table',{'class':'wikitable sortable plainrowheaders jquery-tablesorter'})
print(table)
返回:无