LXml Xpath处理多行字段
我正在对页面进行一些抓取,并且可以很好地获取大多数字段,但地址存在一些问题。
<address>
56 South Ave
<br>
Miami, FL 33131
<br>
</address>
address = myWebPage.xpath("//div[contains(@class,'rightcol')]//address")
使用上面的代码我可以得到第一行,56 South Avenue。但我无法获取城市、州、邮政编码。我如何更改代码以获得完整地址?
I'm doing some scraping of a page and I'm fine with getting most fields, but having some problems with the address.
<address>
56 South Ave
<br>
Miami, FL 33131
<br>
</address>
address = myWebPage.xpath("//div[contains(@class,'rightcol')]//address")
I can get the first line, 56 South Avenue, using the above code. But I can't get the city, state, zip. How would I change the code to get the full address?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择
address
的第一个文本节点子节点:选择
address
的第二个文本节点子节点:选择
address
的两个文本节点子节点。selects the first text-node child of
address
:selects the second text-node child of
address
:selects both text-node children of
address
.