Skip to content

Instantly share code, notes, and snippets.

@cheeaun
Created February 14, 2011 14:57
Show Gist options
  • Save cheeaun/825981 to your computer and use it in GitHub Desktop.
Save cheeaun/825981 to your computer and use it in GitHub Desktop.
Updated version of data.html.cssselect Open Data Table for YQL
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<sampleQuery>select * from {table} where url="www.yahoo.com" and css="#news a"</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls>
<url></url>
</urls>
<inputs>
<key id="url" type="xs:string" paramType="variable" required="true" />
<key id="css" type="xs:string" paramType="variable" />
</inputs>
<execute><![CDATA[
//include css to xpath convert function
y.include("http://css2xpath.googlecode.com/files/css2xpath.min.js");
var query = null;
if (css) {
var xpath = css2xpath(css);
y.log("xpath "+xpath);
query = y.query("select * from html where url=@url and xpath=\""+xpath+"\"",{url:url});
} else {
query = y.query("select * from html where url=@url",{url:url});
}
response.object = query.results;
]]></execute>
</select>
</bindings>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment