8. On December 4th, 1995
“Netscape and Sun announce JavaScript, a
cross-platform object scripting language”
http://web.archive.org/web/20070916144913/http://wp.netscape.com/newsref/pr/newsrelease67.html
22. It is easy enough to
‘scrape’ the web (using
cURL, wget, etc...), but
how do you parse it?
23. It is easy enough to
‘scrape’ the web (using
cURL, wget, etc...), but
how do you parse it?
XPath + DOM Traversal = Yay!
24. It is easy enough to
‘scrape’ the web (using
cURL, wget, etc...), but
how do you parse it?
XPath + DOM Traversal = Yay!
Regular Expressions = Double Yay!
25. It is easy enough to
‘scrape’ the web (using
cURL, wget, etc...), but
how do you parse it?
26. “If a regular expression
is longer than 2 inches,
find another method”
- Douglas Crockford
43. "Yahoo! Query Language is an
expressive SQL-like language that
lets you query, filter, and join data
across Web services.
With YQL, apps run faster with
fewer lines of code and a smaller
network footprint."
http://developer.yahoo.com/yql/
46. How do you use it?
$format = “json”; // or xml;
47. How do you use it?
$format = “json”; // or xml;
$base = “http://query.yahooapis.com/v1/public/yql”;
48. How do you use it?
$format = “json”; // or xml;
$base = “http://query.yahooapis.com/v1/public/yql”;
$url = “{$base}?q={$yql_query}&format={$format}”;
49. How do you use it?
$format = “json”; // or xml;
$base = “http://query.yahooapis.com/v1/public/yql”;
$url = “{$base}?q={$yql_query}&format={$format}”;
$json_string = goGetIt($url); // likely a curl() call
50. How do you use it?
$format = “json”; // or xml;
$base = “http://query.yahooapis.com/v1/public/yql”;
$url = “{$base}?q={$yql_query}&format={$format}”;
$json_string = goGetIt($url); // likely a curl() call
$data = json_decode($json);
51. How do you use it?
$format = “json”; // or xml;
$base = “http://query.yahooapis.com/v1/public/yql”;
$url = “{$base}?q={$yql_query}&format={$format}”;
$json_string = goGetIt($url); // likely a curl() call
$data = json_decode($json);
Or use any of the libraries written for
your favorite language/framework
58. SELECT * FROM
foursquare.history
WHERE
username=“foo” AND
password=“bar”
59. SELECT * FROM rss WHERE
url IN (SELECT title FROM
atom WHERE url="http://
spreadsheets.google.com/feeds/list/
pg_T0Mv3iBwIJoc82J1G8aQ/od6/public/
basic")
LIMIT 10 |
unique(field="title")
75. YQL != Voodoo Magic
It is just rewriting a YQL
query into one (or many)
HTTP calls for you.
76. USE "http://www.datatables.org/nyt/nyt.bestsellers.xml"
AS nyt.bestsellers;
USE "https://github.com/gcb/yql.opentable/raw/master/
text.concat.xml"
AS text.concat;
SELECT text FROM text.concat
WHERE text.key1 = "http://www.amazon.com/dp/" AND
(text.key2) IN (
SELECT isbns.isbn.isbn10
FROM nyt.bestsellers
WHERE apikey='yourAPIKey'
);
// Generates strings like “http://www.amazon.com/dp/031603617X”
80. <execute>
• Execute arbitrary JavaScript in Rhino (a JS engine)
• E4X Support (XML literals in JS)
• Speak protocols and handle authentication;
Basic auth, OAuth, XAuth, XMLRPC, ...
• Best feature? View-source!
81. Summary
• YQL is very useful for...
• Scraping
• Creating an API where one doesn’t exist
• Converting XML -> JSON, & vice-versa
• JSONP for JS-only apps
• Many HTTP requests -> single HTTP request
• Server-side JS processing
83. Get started @
http://developer.yahoo.com/yql
Thanks!
Questions? Find, Tweet, or Email me.
@derek or drg@yahoo-inc.com
Editor's Notes
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
You now have a common way of accessing any data on the web, with or without APIs, and all in one common syntax that you are likely familiar with, SQL.\n