YQL (Yahoo Query Language)

Yahoo Query Language es el lenguaje  mediante el cual se puede consultar las API’s de yahoo.

De sintaxis similar a SQL permite consultar información de diversos servicios web en su terminología llamados tablas.

Ejemplo consulta página web:

select * 
from html 
where url="http://www.puigverd.org" and xpath="//ul[@class='nose']"

Ejemplo consulta RSS

select *
from rss
where url="http://www.infojobs.net/trabajos.rss/p_31/"

Ejemplo de consulta a google trasnlator:

SELECT * 
FROM google.translate 
WHERE q="This is a test" and target="de";

Para la ejecución de las sentencias
Consola YQL

http://developer.yahoo.com/yql/console/

Python

import urllib2,json
try:
	result = urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20*%20%0Afrom%20rss%20%0Awhere%20url%3D%22http%3A%2F%2Fwww.infojobs.net%2Ftrabajos.rss%2Fp_31%2F%22&format=json&diagnostics=true&callback=").read()
except:
	print "I am unable to connect to the url"
	print e.reason
	exit(0)
data = json.loads(result)
print data

PHP

<?php
$xml = simplexml_load_file('

http://query.yahooapis.com/v1/public/yql?q=

	SELECT * FROM music.release.popular
	');

echo '<h2>Popular Music</h2>';
$results = $xml->results;
foreach ($results->Release as $r) {
	echo '<p>';
	echo '<a href="' . $r['url'] . '">' . $r['title'] . 
	'</a> (' . $r['releaseYear'] . ') - ';  
	echo '<a href="' . $r->Artist['url'] . '">' . $r->Artist['name'] . 
	'</a> <br/>';  
	echo '</p>';
}  
?>

JQUERY

$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20%0Afrom%20html%20%0Awhere%20url%3D%22http%3A%2F%2Fwww.puigverd.org%22%20and%20xpath%3D%22%2F%2Fspan%5B%40class%3D'site-description'%5D%22&format=json&diagnostics=true&callback=",
		  function(data) {
			  var id = data.query.results;
			  console.log(id)
		  }
		);
Posted in Uncategorized