雅虎yql_从RSS Feed和YQL创建数据表
雅虎yql
- Yahoo Query Language( YQL )是一种查询语言,例如SQL。
- 使用YQL,我们可以跨Web服务 查询 , 过滤和联接数据。
- YQL也可以阅读RSS feed。
- 响应可以是JSON或XML。
- 雅虎提供了一个YQL控制台,用于调试 , 测试和诊断 YQL语句。
- YQL控制台的链接为http://developer.yahoo.com/yql/console/
- 该演示显示:
- 使用YQL阅读我的博客RSS Feed(http://www.tutorialsavvy.com/feeds/posts/default)。
- 获取JSON格式的供稿。
- 在YUI3数据表中显示数据。
- 项目结构
- 本演示使用以下yui3模块' node ',' yql ',' datatable ',' datatable-scroll ',' datatype-date '。
- 使用的YQL语句是: 选择标题,发布日期,来自rss的链接,其中url ='http://www.tutorialsavvy.com/feeds/posts/default?alt = rss&format = json&diagnostics = true'
- YQL控制台输出为:
- YQL演示脚本yql-demo.htmlHTML标记
<!DOCTYPE html>
<html><head><title>YQL Query Reading RSS Feed Demo</title><script src='http://yui.yahooapis.com/3.8.1/build/yui/yui-min.js'></script><style>.response-status {font-weight: bold;color:grey;list-style: none;}.response-text {font-size:16px;color : orange;}#yui-blogger-rss-feed-table {width:650px;}.yui3-skin-sam #yui-blogger-rss-feed-table .yui3-datatable-cell {font-size:11px;}.blogger-post-title {color: Green;font-style: italic;font-weight: bold;}.blogger-post-link {text-decoration: none;font-style: italic;font-weight:bold;}.blogger-post-link:hover {color:orange;text-decoration: underline;font-weight:bold;}</style></head><body class='yui3-skin-sam'><!-- This DIV Element is for displaying posts from the YQL QUERY RESPONSE(JSON)details in YUI3 DATATABLE --><div id='yui-blogger-rss-feed-table'></div><!-- This UL Element is for displaying post count, created date,language --><ul class='response-status'></ul><script>YUI().use('node', 'yql', 'datatable', 'datatable-scroll', 'datatype-date', function (Y) {var resultItems,results, postTable,/*This YQL query is for my Blogger's RSS feed.*/yqlRssUrl = 'select title, pubDate, link from rss where ' +'url='http://www.tutorialsavvy.com/feeds/posts/default?alt=rss&format=json&diagnostics=true'',responseStatus = Y.one('.response-status'),rssYqlFeedTable = Y.one('#yui-blogger-rss-feed-table'),/*HTML template for LINK of the post*/formatLink = '<td class='yui3-datatable-cell'><a class='blogger-post-link' href='{content}'>{content}</a></td>',/*HTML template for TITLE of the post*/formatTitle = '<td class='yui3-datatable-cell blogger-post-title'>{content}</td>',/*Formatter function for formatting a date, pubDate*/formatPubDate = function (o) {return Y.DataType.Date.format(Y.DataType.Date.parse(o.value), {format: '%Y-%m-%d'});}/* This will return 25 results As Blogger return 25 posts by DEFAULT.* This can be changed to some other number using* LIMIT parameter.*/Y.YQL(yqlRssUrl, function (feed) {results = feed.query;resultItems = feed.query.results.item;responseStatus.appendChild('<li> Count of Posts (in response) : <span class='response-text'>' + results.count + '</span></li>');responseStatus.appendChild('<li>Created Date : <span class='response-text'>' + results.created + '</span></li>');responseStatus.appendChild('<li>Post Language : <span class='response-text'>' + results.lang + '</span></li>');postTable = new Y.DataTable({columns: [{key: 'title',label: 'POST TITLE',cellTemplate: formatTitle},{key: 'pubDate',label: 'PUBLICATION DATE',formatter: formatPubDate},{key: 'link',label: 'POST LINK',cellTemplate: formatLink}],data: resultItems,scrollable: 'y',height: '250px',caption: '[ YQL READING RSS FEED FROM TUTORIAL SAVVY(http://www.tutorialsavvy.com/feeds/posts/default)' + 'AND DISPLAYING IN DATATABLE]'}).render(rssYqlFeedTable);})});</script></body></html>
- 萤火虫检查
- 该演示的JS Fiddle链接为:
http://jsfiddle.net/techblogger/sr67C/2/embedded/result/
- JS小提琴输出:
输出(屏幕截图):
演示代码下载:
下载代码链接
参考: My Small Tutorials博客上的JCG合作伙伴 Sandeep Kumar Patel 从RSS Feed和YQL创建数据表 。
翻译自: https://www.javacodegeeks.com/2013/02/creating-datatable-from-rss-feed-and-yql.html
雅虎yql
雅虎yql_从RSS Feed和YQL创建数据表相关推荐
- 从RSS Feed和YQL创建数据表
Yahoo Query Language( YQL )是一种查询语言,例如SQL. 使用YQL,我们可以跨Web服务 查询 , 过滤和联接数据. YQL也可以阅读RSS feed. 响应可以是JSON ...
- Python使用SQLAlchemy连接数据库并创建数据表、插入数据、删除数据、更新表、查询表(CRUD)
Python使用SQLAlchemy连接数据库并创建数据表.插入数据.删除数据.更新表.查询表(CRUD) 目录 Python使用SQLAlchemy连接数据库并创建数据表 #SQLAlchemy # ...
- MySQL 创建数据表
MySQL 创建数据表 创建MySQL数据表的SQL语法: CREATE TABLE table_name (column_name column_type); 例如,我们在 PENGKE 数据库中创 ...
- XamarinSQLite教程创建数据表
XamarinSQLite教程创建数据表 新创建的数据库没有任何表.开发者需要手动添加数据表,并添加测试所需的数据. 1.创建数据表 为了存储数据,开发者需要添加自己的表,并设计表的结构.操作步骤如下 ...
- mysql user表添加记录_《MySQL数据操作与查询》- 返校复习课练习题,创建数据库user_system,创建数据表user及user_ext...
一.其它(共18题,100分) 1.创建数据库user_system CREATE DATABASE user_system 2.在数据库user_system中创建数据表user及user_ext, ...
- Oracle 创建数据表以及对数据表、字段、主外键、约束的操作
选择主键的原则: 最少性 尽量选择使用单个键作为主键 稳定性 尽量选择数值更新少的列作为主键 1.创建数据表(CREATE TABLE) --创建数据表Student create table Stu ...
- mysql if exists 数据表_使用IF NOT EXISTS创建数据表
如果简单的使用如下sql语句可能会返回失败,失败的原因极有可能是已经存在这张数据表了. 如果简单的使用如下sql语句可能会返回失败,失败的原因极有可能是已经存在这张数据表了. create table ...
- 利用T-SQL语句创建数据表
创建表的另一种方式是输入代码进行创建. 在连接上需要操作的地址后,选择数据库,从中通过查询--创建查询进行操作,出现下面的界面: 在这里输入代码进行表格的创建: create table为创建表: p ...
- MySQL创建数据表(CREATE TABLE语句)
在创建数据库之后,接下来就要在数据库中创建数据表.所谓创建数据表,指的是在已经创建的数据库中建立新表. 创建数据表的过程是规定数据列的属性的过程,同时也是实施数据完整性(包括实体完整性.引用完整性和域 ...
最新文章
- 如何查看matlab的启动参数,如何使用多个参数在Matlab中执行“查找”?
- char和varchar的区别以及尾部空格问题 - sqlserver演示
- C++ 通讯录学习总结
- Android攻城狮Gallery和ImageSwitcher制作图片浏览器
- 区域数据导入功能(在服务端接收上传文件)
- thinkphp5 内置接口开发与使用
- .net测试篇之单元测试/集成测试神器Autofixture
- Linux下如何编译并运行C程序
- java cache教程_Java 中常用缓存Cache机制的实现
- MySQL中with rollup的用法
- 计算机网络dns实验报告,计算机网络DNS以及HTTP协议实验报告
- 李彦宏:Apollo Moon共享无人车必须要比打车便宜;消息称iPhone 12 mini已停产;抖音网页版上线|极客头条...
- 在WPF中自定义你的绘制(二)
- webpack 安装vue(两种代码模式compiler 和runtime)
- 用极限可以求瞬时速度的道理
- Atitit. 构造ast 语法树的总结attilax oao
- codeup3692 星期英文单词
- mysql 内置函数大全 mysql内置函数大全
- 【JVM】Java IDEA 配置项目的JVM运行内存大小
- 优矿API实现一个双均线策略