【问题标题】:Yahoo Pipes to enrich RSS descriptions dynamically with ${title} variable?Yahoo Pipes 使用 ${title} 变量动态丰富 RSS 描述?
【发布时间】:2013-05-27 16:07:10
【问题描述】:

在 Yahoo Pipes 中,通过使用 Regex 模块,我可以将 item.link .* 替换为诸如 https://www.google.com/webhp#output=search&sclient=psy-ab&q=${title}

之类的 url

这样做的目的是假设提要的标题是“巴拉克奥巴马访问俄克拉荷马”,该标题现在将使用 ${title} 变量链接到谷歌搜索词“巴拉克奥巴马访问俄克拉荷马”。

但我想做的是在描述中添加脚本,这样我就可以做一些事情,比如使用http://gdata.youtube.com/feeds/api/videos?max-results=1&alt=rss&q=${title} 的 rss 输出嵌入 youtube 视频并显示相关标题的图像,flickr rss 输出为http://www.flickr.com/services/feeds/photos_public.gne?tags=${title}&format=rss_200

有没有办法做到这一点?可以用 Yahoo 的 Pipes YQL 模块来完成吗?是否有其他服务可以执行此功能?

谢谢!

【问题讨论】:

    标签: xml rss pipe yahoo yql


    【解决方案1】:

    YQL 有一个执行方法,可以在输出上运行 JavaScript 以将其转换为所需的格式。以下是几个例子:

    <execute><![CDDATA[
    // request.url == 'http://some_web_service_or_feed
    // This is the same as 'y.rest(request.url).get();'
    var returned_response = request.get();
    ...
    ]]>
    </execute>
    
    <execute><![CDATA[
    // Include the OAuth libraries from oauth.net
    y.include("http://oauth.googlecode.com/svn/code/javascript/oauth.js");
    y.include("http://oauth.googlecode.com/svn/code/javascript/sha1.js");
    
    // Collect all the parameters
    var encodedurl = request.url;
    var accessor = { consumerSecret: cs, tokenSecret: ""};
    var message = { action: encodedurl, method: "GET", parameters: [["oauth_consumer_key",ck],["oauth_version","1.0"]]};
    OAuth.setTimestampAndNonce(message);
    
    // Sign the request
    OAuth.SignatureMethod.sign(message, accessor);
    
    try {
       // get the content from service along with the OAuth header, and return the result back out
        response.object = request.contentType('application/xml').header("Authorization", OAuth.getAuthorizationHeader("netflix.com", message.parameters)).get().response;
        } catch(err) {
        response.object = {'result':'failure', 'error': err};
        }
    ]]>
    </execute>
    

    参考文献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      相关资源
      最近更新 更多