Ok, so I'm a bit tiffed at Yahoo right now (I'll put my rant at the end) but I can't not be excited about this. Luke S. emailed me a week or two and suggested I take a look at this blog entry: Tutorial: Scraping and tuning a web site into a widget with YQL. This blog entry discusses how you can use YQL (Yahoo Query Language) as a way to arbitrarily parse random HTML pages. He discusses how he uses XPATH against the HTML to parse up the data and reuse it. I thought this was cool - but then I began looking at the YQL docs more closely and found that this was just the tip of the iceberg.
Yahoo's built what amounts to a SQL interface to both the web and it's own data services. So along with doing XPATH parses on HTML pages, you can also search against flickr:2 select * from html(0,10) where url='http://www.dcs.gla.ac.uk/~joy/fun/jokes/TV.html' and xpath='//ul/li/p'
3 </cf_yql>
4
5 <cfdump var="#results#">
6
7 <cf_yql name="results2">
8 SELECT * FROM flickr.photos.search WHERE text='coldfusion'
9 </cf_yql>
10 <cfdump var="#results2#">
11
12 <cf_yql name="results3">
13 select title,abstract,url from search.web(0,10) where query='coldfusion'
14 </cf_yql>
15 <cfdump var="#results3#">
The actual custom tag isn't too complex. Remember ColdFusion makes it simple to get content between tags:
2
3 <!--- get the yql --->
4 <cfset yql = thisTag.generatedContent>
5 <!--- remove it --->
6 <cfset thisTag.generatedContent = "">
7
8 <cfset yql = trim(urlEncodedFormat(yql))>
2 <cfset data = result.fileContent.toString()>
3 <!--- convert json to CF --->
4 <cfset data = deserializeJSON(data)>
ydn @cfjedimaster we didn't get a renewed interest in #coldfusion from our community and we've been trying to streamline our site/offeringsI protested this (well, on Twitter) but have yet to get a response. I also posted my query to their forums. I'd really appreciate it folks ping them - either via Twitter or their forums, and let them know that you want to see ColdFusion represented. Crap - the content was written. They didn't have to pay anything for it (and I'd gladly keep it updated) so this should be a no brainer for them. Shoot - they have a Silverlight developer center. You can't tell me there are more SL devs then ColdFusion.
Comment 1 written by Ryan LeTulle on 10 September 2009, at 5:34 PM
Silverlight doesn't surprise me now especially with their Microsoft relationship.
Comment 2 written by Francois Levesque on 10 September 2009, at 6:10 PM
Nice find, Ray!
Comment 3 written by Dan G. Switzer, II on 10 September 2009, at 6:37 PM
Comment 4 written by Todd Rafferty on 10 September 2009, at 8:26 PM
Comment 5 written by thinman on 10 September 2009, at 8:27 PM
It looks like Pipes may also go away too, they're sure sounding like they're looking for stuff to get rid of that would give MS competition.
Comment 6 written by Raymond Camden on 10 September 2009, at 8:48 PM
@Thinman: Worse comes to worse, I'll post my copy of the files.
Comment 7 written by Raymond Camden on 10 September 2009, at 8:50 PM
Comment 8 written by Jonathan on 10 September 2009, at 8:51 PM
Comment 9 written by felix tjandrawibawa on 10 September 2009, at 9:10 PM
It's really awesome!
I played around w/ it few months ago:
http://tech.tjandrawibawa.org/blog/2009/07/01/expe...
Comment 10 written by Luke on 11 September 2009, at 3:32 AM
as for YDN - *grrrrr*, shall ping.
Comment 11 written by Rudi on 11 September 2009, at 5:11 AM
Good Stuff. I've been using the pipes feed from Yahoo for a while and have only scratched the surface with what is possible. I would very interested in the cf_yahoo package.
-Rudi
Comment 12 written by Todd Rafferty on 11 September 2009, at 5:22 AM
http://www.railo.ch/blog/index.cfm/2009/9/11/CFC-C...
Comment 13 written by Raymond Camden on 11 September 2009, at 6:53 AM
Comment 14 written by Lola LB on 11 September 2009, at 9:24 AM
Shame they removed the CF Developer content. I've left a comment on their forum.
Comment 15 written by Rudi on 11 September 2009, at 12:15 PM
Yes, that's what I meant. That's what I get for posting before the caffeine kicks in.
Comment 16 written by Ben Nadel on 16 September 2009, at 8:03 AM
Comment 17 written by Raymond Camden on 16 September 2009, at 11:10 AM
Comment 18 written by Ben Nadel on 16 September 2009, at 11:11 AM
Are you so badass that you actually got them to change their mind :D
Comment 19 written by Raymond Camden on 16 September 2009, at 11:17 AM
The ColdFusion Army is strong!
Comment 20 written by Ben Nadel on 16 September 2009, at 11:18 AM
Comment 21 written by cf_Ray on 24 September 2009, at 5:31 AM
Awesome post MrCamden!
Comment 22 written by Raymond Camden on 24 September 2009, at 6:47 AM
Comment 23 written by TomasF on 28 September 2009, at 6:27 AM
Element 1 is undefined in a CFML structure referenced as part of an expression.
47 : <cfif isSimpleValue(data.query.results[key][1])>
Trying to figure it out, but I'll probably never get there, I'm a sysadmin and shouldn't be doing this in the first place ;)
Comment 24 written by Raymond Camden on 29 September 2009, at 12:41 PM
Grab the bits here: http://www.coldfusionjedi.com/downloads/yql2.zip
Comment 25 written by Raymond Camden on 29 September 2009, at 12:43 PM
Comment 26 written by Raymond Camden on 29 September 2009, at 12:45 PM
http://www.coldfusionjedi.com/downloads/yql3.zip
Comment 27 written by Misty on 29 September 2009, at 8:03 PM
Comment 28 written by William Greenly on 2 October 2009, at 7:07 AM
Another alternative is a to provide an xQuery parser e.g
<cf_XQuery name="results">
for $i in document("http://www.dcs.gla.ac.uk/~joy/fun/jokes/TV.html&qu...;)
return $i//ul/li/p
</CF_XQuery>
This provides more expressiveness than SQL and xpath combined.
I have developed a custom tag to provide this functionality at:
http://www.cfxquery.co.uk/CF-XQuery-tags-CFXQuery....
Many Thanks,
Will
Comment 29 written by Raymond Camden on 2 October 2009, at 8:23 AM
[Add Comment] [Subscribe to Comments]