【发布时间】:2019-08-03 19:49:10
【问题描述】:
我正在使用 beautifulsoup 进行网页抓取,虽然我的循环输出了正确的信息,但它并没有分成不同的行。应该有 4 列(邮政编码、城市、县、类型)和许多行。
Table2=""
for tr in Table1.find_all('tr'):
row=""
for tds in tr.find_all('td'):
row=row+","+tds.text
Table2=Table2+row[1:]
print(Table2)
看起来像这样:
01001,Agawam,Hampden,Standard 01002,Amherst,Hampshire,Standard 01003,Amherst,Hampshire,Standard 01004,Amherst,Hampshire,P.O.盒子
我想要单独的行,每行都以邮政编码开头。
【问题讨论】:
标签: python loops web-scraping beautifulsoup