【发布时间】:2014-06-26 09:57:40
【问题描述】:
晚上好。 我得到以下html代码:
<tr>
<td>value:</td>
<td>0</td>
</tr>
此代码是完整 html 网页的一部分。 我想解析第二个 td-tag 中的值。
这是我的尝试:
pattern = re.compile('<td>value:</td>.*?<td>(.*?)</td>', re.S)
value = pattern.search(source_code).group(1)
source_code是完整的网页源代码。
当我运行此代码时,我收到以下消息:
AttributeError: 'NoneType' object has no attribute 'group'
【问题讨论】:
标签: python html regex html-parsing