用 Beautiful Soup 和 pandas 拼桌子
Scrape tables with Beautiful Soup and pandas
我一直在尝试用漂亮的汤抓取 table 以将变量放入一个对象中,但它以三个对象返回我的结果。我试图将它们放在一个列表中,但我需要将它们放在一个对象中
for table in priceTable:
td= table.find_all('td')
row=[i.text for i in td]
print(name, row)
而这个 returns 我是三个不同对象的结果
[example1][example2][example3]
您似乎在分别打印每个对象。如果您希望它们一起打印,或者在一个对象中以便将来执行代码,请尝试将每个结果放入一个列表中,然后打印该列表。
foolist = []
for table in priceTable:
td= table.find_all('td')
row=[i.text for i in td]
foolist.append(row)
print(foolist)
for foo in foolist:
foo += " bar"
我一直在尝试用漂亮的汤抓取 table 以将变量放入一个对象中,但它以三个对象返回我的结果。我试图将它们放在一个列表中,但我需要将它们放在一个对象中
for table in priceTable:
td= table.find_all('td')
row=[i.text for i in td]
print(name, row)
而这个 returns 我是三个不同对象的结果
[example1][example2][example3]
您似乎在分别打印每个对象。如果您希望它们一起打印,或者在一个对象中以便将来执行代码,请尝试将每个结果放入一个列表中,然后打印该列表。
foolist = []
for table in priceTable:
td= table.find_all('td')
row=[i.text for i in td]
foolist.append(row)
print(foolist)
for foo in foolist:
foo += " bar"