【发布时间】:2013-09-18 07:50:57
【问题描述】:
我是 webharvest 的新手,我正在使用它从网站获取文章数据,使用以下语句:
let $text := data($doc//div[@id="articleBody"])
这是我从上述语句中得到的数据:
The Refine Spa (Furman's Mill) was built as a stone grist mill along the on a tributary of Capoolong Creek by Moore Furman, quartermaster general of George Washington's army
Notable people
Notable current and former residents of Pittstown include:
我的问题是,是否可以从另一个字符串中减去一个字符串 在上面的示例中:内容中的“名人”。
这样可以吗?如果可能,请让我知道如何。谢谢。 有什么我可以这样做的吗:
if (*contains*($text, 'Notable people')) then $text := *minus*($text, 'Notable people')
contains 是一个示例函数名,用于确定一个字符串是另一个字符串的子字符串, minus 是从另一个中删除子字符串的示例函数名称
想要的输出:
The Refine Spa (Furman's Mill) was built as a stone grist mill along the on a tributary of Capoolong Creek by Moore Furman, quartermaster general of George Washington's army
Notable current and former residents of Pittstown include:
【问题讨论】:
-
当然可以,您可以通过手动搜索和制作子字符串或使用正则表达式/文字替换来做到这一点
-
有一个 java 函数可以执行 String 减号 我发现这个:web-harvest.sourceforge.net/manual.php#function 关于如何定义自己的函数。如果有办法从 web 收获中调用 java 函数?
标签: java javascript web-scraping screen-scraping webharvest