解析维基百科列表并将结果存储到二维数组中

时间:2012-04-15 14:09:05

标签: python html parsing beautifulsoup

This is the page我对解析很感兴趣。解析后,我想将结果存储到二维数组中。任何人都可以请问我应该如何解决这个问题?这是我尝试使用BeautifulSoup的代码。 html包含上述网址中的html。

soup = BeautifulSoup(html)
temp = soup.find_all('li')
#for x in temp :
#    print x.text

table = []
for x in temp :
    row = []
    index = x.text.find(' - ',0)
    row.append(x.text[0:index-1])
    row.append(x.text[index+3:])
    table.append(row)

for row in table :
    print row

0 个答案:

没有答案
相关问题