刮表在这第一个代码,我可以用BS获取感兴趣的表中的所有信息:与BeautifulSoup
from urllib import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.pythonscraping.com/pages/page3.html")
soup = BeautifulSoup(html)
for i in soup.find("table",{"id":"giftList"}).children:
print child
,打印的产品清单。
我想在tournamentTable
here打印的行(所需的信息是class=deactivate
,在class=center nob-border
class=odd deactivate
和日期):
from urllib import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.oddsportal.com/hockey/russia/khl/results/#/page/2.html")
soup = BeautifulSoup(html)
#for i in soup.find("table",{"id":"tournamentTable"}).children:
# print i
for i in soup.find("table",{"class":"table-main"}).children:
print i
但这种情况正在打印页面上的其他表。当我尝试使用{"id":"tournamentTable"}
指定感兴趣的表时,它将返回Nonetype
。
我错过了什么,我无法访问所需的表&的信息?
也许这部分是由JavaScript创建的 - urllib/bs不支持javascript。 – furas