有一个网站,例如:
http://example.com
使用这样的页面:
<div id="topnews">
<a href="/news/topnews1.html"> Top news1 </a>
<a href="/news/topnews2.html"> Top news2 </a>
<a href="http://sport.example.com/news/topnews3.html"> Top news complex </a>
</div>
纯粹使用XPath是否能够获取这三个URL:
http://example.com/news/topnews1.html
http://example.com/news/topnews2.html
http://sport.example.com/news/topnews3.html
为了提取相对URL,我们可以使用以下方法:
//div/a/@href
但是,
concat('http://example.com', //div/a/@href)
只返回一行数据(第一行),而不是三个不同的值。
我不知道如何优雅地检测和处理最后一个完整的URL。