【发布时间】:2015-07-03 08:38:03
【问题描述】:
我正在尝试解析网页中的 HTML 表格,我将其作为字符串输入传递给 BeautifulSoup。我已经给出了以下脚本来解析 HTML 页面并在 CSV 文件中打印内容:
soup = BeautifulSoup(In_put)
comments = soup.find_all('td', {"id": "TicketDetails_TicketDetail_TicketDetail__ctl0_Tablecell1"})
f = open(Out_put, 'w')
writer = csv.writer(f)
for s in comments:
writer.writerow(s.split('##'))
f.close()
但它显示一个错误说:
Traceback (most recent call last):
File "C:/Users/KOS974/PycharmProjects/test_cases/gasper_try.py", line 561, in <module>
writer.writerow(s.split('##'))
TypeError: 'NoneType' object is not callable
我真的无法理解为什么会出现错误,即使<tr> 标记中的某些内容具有相同的id。
【问题讨论】:
标签: python html parsing csv beautifulsoup