在 Yahoo Pipes 中获取纯文本
我有一个雅虎管道从 Google 群组获取 Atom 提要,并且我想对消息的全文进行一些处理(运行各种正则表达式来提取数据)。我可以使用如下网址从 Google 获取纯文本消息文本:
http://groups.google.com/group/(group_name)/msg/(message_id)?dmode=source&output=gplain
但是,我无法将其作为字符串值放入雅虎管道中。获取页面拒绝非 HTML 页面。使用 html 表的 YQL 似乎可以工作,并将纯文本包装在 ap 元素内,我可以像这样提取其文本:
select * from html where url="..." and xpath="//p"
但是,如果消息文本包含 html 标签,YQL 将返回 HTML 子树而不是字符串。有什么方法可以将其恢复为 HTML 源代码吗?
I have a Yahoo pipe taking the Atom feed from a Google group, and I want to do some processing on the message's full text (running various regular expressions to extract data). I can get a message's text in plain text from from Google using a url like this:
http://groups.google.com/group/(group_name)/msg/(message_id)?dmode=source&output=gplain
However, I'm having trouble getting it inside Yahoo pipes as a string value. Fetch Page rejects non-HTML pages. YQL using the html table seems to work, and wraps the plain text inside a p element, whose text I can extract like this:
select * from html where url="..." and xpath="//p"
However, if the message text contains html tags, YQL returns an HTML subtree instead of a string. Is there any way of flattening it back into its HTML source?
诀窍是删除“output=gplain”并从 pre 元素中获取内容。
我创建了一个以 Google 群组和消息 ID 作为输入的管道来演示:
http:// /pipes.yahoo.com/pipes/pipe.info?_id=3d345e162405e7dbd47d73b95c21f102
The trick is to remove the "output=gplain" and grab the content from the pre element.
I have created a pipe with Google Group and Message ID as inputs to demonstrate:
http://pipes.yahoo.com/pipes/pipe.info?_id=3d345e162405e7dbd47d73b95c21f102