BeautifulSoup - 在维基百科页面上查找具有指定类的表

Tom*_*Tom 4 python beautifulsoup

我正在尝试使用BeautifulSoup在维基百科页面中找到一个表格,由于某种原因,我没有得到该表格.任何人都可以告诉我为什么不拿桌子?

我的代码:

import BeautifulSoup
import requests

url='https://en.wikipedia.org/wiki/List_of_National_Historic_Landmarks_in_Louisiana'
r=requests.get(url)
url=r.content
soup = BeautifulSoup(url,'html.parser')

tab=soup.find("table",{"class":"wikitable sortable jquery-tablesorter"})
print tab
Run Code Online (Sandbox Code Playgroud)

打印:无

wpe*_*rcy 12

您不应该jquery-tablesorter在请求获得的响应中选择反对,因为它是在页面加载后动态应用的.如果你省略,你应该好好去.

tab = soup.find("table",{"class":"wikitable sortable"})
Run Code Online (Sandbox Code Playgroud)