Webscraping美丽的汤 - 表过早结束?

时间:2016-07-10 12:36:27

标签: python web-scraping beautifulsoup wikipedia

我正在尝试使用BeautifulSoup学习python中的webscraping。我有点陷入困境。我试图抓住这个维基百科页面;

https://en.wikipedia.org/wiki/List_of_MPs_elected_in_the_United_Kingdom_general_election,_2015

特别是在大选中当选的国会议员名单表。

到目前为止我的代码是;

main_page = 'https://en.wikipedia.org/wiki/List_of_MPs_elected_in_the_United_Kingdom_general_election,_2015'

page= requests.get(main_page)
soup = BeautifulSoup(page.text, "lxml")
table = soup.find("table", class_="wikitable sortable")

当我尝试查看变量表时,它似乎过早停止,以下是表中的最后一行;

<tr>\n<td><a href="/wiki/Carmarthen_East_and_Dinefwr_(UK_Parliament_constituency)" title="Carmarthen East and Dinefwr (UK Parliament constituency)">Carmarthen East and Dinefwr</a></td>\n<td style="background-color: #008142"></td>\n<td><a href="/wiki/Plaid_Cymru" title="Plaid Cymru">Plaid Cymru</a></td>\n<td style="background-col"></td></tr>

然而,维基百科上的表格还有数百行。有谁知道为什么我无法获取剩余的数据?

0 个答案:

没有答案