2015-11-17 28 views
1

我正在尝试使用BeautifulSoup在维基百科页面中找到一张表格,出于某种原因,我没有收到表格。 任何人都可以告诉我为什么我不拿桌子吗?beautifulsoup-找到指定类别的表格

我的代码:

import BeautifulSoup 

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 

打印:无

+0

你能明确指定你正在使用的模块吗? 'requests.get'从哪里来? – DJJ

+0

@DJJ'requests.get'来自[请求库](http://docs.python-requests.org/en/latest/) – Celeo

回答

3

你不应该使用jquery-tablesorter选择针对您的请求得到,因为它是在页面加载后动态应用的响应。如果你忽略了这一点,你应该很好走。

tab = soup.find("table",{"class":"wikitable sortable"})