【发布时间】:2016-04-28 20:59:13
【问题描述】:
我想使用 xpath 优化我的 Xidel 输出://BODY/DIV 删除包含“AClass”的行,并仅保留包含“MyClass”的行
我可以在 Xidel 输出文件中添加换行符吗?
<a class="AClass" href="http://www.mywebsite.com/file1" target="_blank"> File1 </a>
<a class="AClass" href="http://www.mywebsite.com/file2" target="_blank"> File2 </a>
<a class="AClass" href="http://www.mywebsite.com/file3" target="_blank"> File3 </a>
<a class="AClass" href="http://www.mywebsite.com/file4" target="_blank"> File4 </a>
<a class="MyClass" href="http://www.mywebsite.com/file5" target="_blank"> File5 </a>
<a class="AClass" href="http://www.mywebsite.com/file6" target="_blank"> File6 </a>
<a class="MyClass" href="http://www.mywebsite.com/file7" target="_blank"> File7 </a>
【问题讨论】:
-
您使用的是哪个 XPath 表达式?
//body/div将返回divs 的列表,而不是as。通常可以使用[]或except进行过滤
标签: html web-scraping xidel