这是我正在分析的网站:http://uniapple.net/usaddress/address.php?address1=501+10th+ave&address2=&city=nyc&state=ny&zipcode=10036&country=US
我希望能够在td标签之间的第39行找到单词。这一行告诉我地址是住宅地址还是商业地址,这正是我编写脚本所需要的。在
这是我所拥有的,但是我得到了一个错误:
AttributeError: 'NoneType' object has no attribute 'find_next'
我使用的代码是:
^{pr2}$
Tags:
text
参数在这种特殊情况下不起作用。这与如何计算元素的^{get_text()
并检查包含子节点的元素的完整“文本”:打印
Commercial
。在我们可以更进一步,创建一个可重用函数以通过标签获得值:
^{pr2}$印刷品:
你只缺一点家务活:
您需要使用正则表达式作为文本字段,如
re.compile('Residential or')
,而不是字符串。在这对我很有用。我不得不反复查看提供的结果,但是如果您只希望每个页面都有一个结果,您可以将
find
替换为find_all
:相关问题 更多 >
编程相关推荐