I am a bounteous follower of YQL, a abominably cushy and fuss-free artefact to admittance APIs and intermixture accumulation retrieved from them in a simple, SQL call language. Say for warning you poverty photos of Paris,France from Flickr that are licensed with Creative Commons attribution, you crapper do this with a azygos command:
-
select * from flickr.photos.info where photo_id in (select id from flickr.photos.search where woe_id in (select woeid from geo.places where text=‘paris,france’) and license=4)
Try it discover here and you wager what I mean.
The incoming travel of this programme was to unstoppered it discover to the public. You crapper delimitate an “Open Table” as a simple XML plan and alter your possess API into this programme with that.
One abstract that’s been executing on my ness to verify the concern most has been eventually free now: YQL execute. Instead of making the YQL module itself such more Byzantine (and thusly streaming in circles) we today earmark you to embed JavaScript in the Open Table XML that module separate on the YQL computer and earmark you to admittance another scheme services, authenticate and bowing HTML with JavaScript and E4X. As Simon Willison place it:
This is nuts (in a beatific way). Yahoo!’s provocative coupler SQL-style XML/JSONP scheme assist programme today supports JavaScript as a category of stored machine language, message you crapper ingest JavaScript and E4X to screen-scrape scheme pages, then ask the results with YQL.
Using this, you crapper augment the warning functionality of YQL to some you need. For example, you crapper bowing HTML with YQL using XPATH, but there was no artefact to ingest CSS selectors. Using an unstoppered plateau that invokes James Padolsey’s css2xpath JavaScript on the computer side, this is today possible.
-
use ‘http://yqlblog.net/samples/data.html.cssselect.xml’ as data.html.cssselect; superior * from data.html.cssselect where url=“www.yahoo.com” and css=“#news a”
The accumulation plateau is pretty easy:
-
<?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 modify function
-
y.include("http://james.padolsey.com/scripts/javascript/css2xpath.js");
-
var ask = null;
-
if (css) {
-
var xpath = CSS2XPATH(css);
-
y.log("xpath "+xpath);
-
ask = y.query("select * from html where url=@url and xpath=\""+xpath+"\"",{url:url});
-
} added {
-
ask = y.query("select * from html where url=@url",{url:url});
-
}
-
response.object = query.results;
-
]]></execute>
-
</select>
-
</bindings>
-
</table>
Check the authorised Yahoo Developer Network journal place on YQL execute for more examples, including marker examples for flickr and netflix.




