如何将Yahoo Pipes项目传递到YQL查询中? [英] How do I pass a Yahoo Pipes item into a YQL query?

查看:103
本文介绍了如何将Yahoo Pipes项目传递到YQL查询中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Yahoo Pipes YQL元素中要做的一件事是将Pipes值传递给YQL查询.例如:

One common thing to want to do in the Yahoo Pipes YQL element is pass in a Pipes value to the YQL query. For example:

select * from html.tostring where url='<someurl>' and xpath='//div[@id="foo"]'

,并且您要传递<someurl>的动态值.假设它是RSS提要项的URL,称为item.link.尝试简单地将带引号的someurl替换为item.link会给您以下错误:

and you want to pass in a dynamic value for <someurl>. Let's say that it's an RSS feed item's URL called item.link. Attempting to simply replace the quoted someurl with item.link gives you this error:

无效的标识符item.link.在这种情况下,我是唯一受支持的标识符

Invalid identifier item.link. me is the only supported identifier in this context

如何传递此值?

推荐答案

您将需要创建一个单独的Pipe,将项目URL作为用户输入,并将其传递给字符串生成器,该字符串生成器将实际URL值替换为YQL查询字符串,并将其作为输入传递到YQL小部件.然后在主管道中,将item.link值作为输入传递到子管道.

You'll need to create a separate Pipe that takes the item URL as user input, passes it into a string builder which substitues the actual URL value into the YQL query string, and pass that as input to the YQL widget. Then in your main pipe, pass the item.link value as the input to your subpipe.

特别是:

  1. 创建用户输入-> URL输入项.您可以给它提供任何名称和提示.设置"Debug"值进行测试会很有帮助.

  1. Create a User inputs -> URL Input item. You can give it any name and prompt. It's helpful to set the "Debug" value for testing.

创建一个包含3个字段的String构建器.在第一个字段中,将字符串放在应替换值的位置.在问题的示例中,select * from html.tostring where url='.在第二个字段中,将URL输入元素的输出连接到此处.在第三个字段中,添加其余的输出:' and xpath='//div[@id="foo"]'.构建字符串时,它将是完整的YQL查询字符串,并替换提供的URL.

Create a String builder, with 3 fields. In the first field, put the string up to where the value should be substituted. In the example in the question, select * from html.tostring where url='. In the second field, connect the output from the URL input element to here. In the third field, add the rest of the output: ' and xpath='//div[@id="foo"]'. When the string is built, it will be a complete YQL query string, with the provided URL substituted in.

创建一个YQL元素,并将字符串构建器的输出连接到查询字段.

Create a YQL element, and connect the output from the string builder to the query field.

将YQL元素输出连接到管道输出"元素.

Connect the YQL elements output to the Pipe Output element.

保存新管道.

在主管道中,创建新管道的元素(我的管道"->您命名"的名称).通常,您会将其拖动到Loop元素中.将输入设置为item.link,您将获得正确的输出.

In your main pipe, create an element of your new pipe (My Pipes -> whatever-you-named-it). Typically you'll be dragging it into a Loop element. Set the input to be item.link and you'll get the proper output.

这篇关于如何将Yahoo Pipes项目传递到YQL查询中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆