Activate your free membership today | Log-in

Monday, June 14th, 2010

JSonduit: Turn the Web into a JSON feed

Category: JSON

<p>Chris Winberry recently built a node-htmlparser library that we posted on. Now we know why he built that library. He has released JSonduit.com:

Any data, anywhere.

JSonduit is a service that can turn practically anything on the web into a JSON feed that any website may consume. A JSON conduit, if you will.

Feeds are created by specifying one or more source URLs and a custom transform, written in JavaScript, that can manipulate the data before the feed is served.

JSonduit also provides a hosting service for web widgets so that any site can easily display JSonduit feeds on their pages. In fact, those recent/popular lists of you see below are actual widgets served by the JSonduit service; all done in a couple of lines of JavaScript (go ahead, view the page source).

To see what it is like to query the world in this manner, check out the most popular feed.... a view on hacker news:

JAVASCRIPT:
  1.  
  2. var result = [];
  3.  
  4. var items = getElements(
  5.     {
  6.         class: "title"
  7.     },
  8.     data[0]
  9. );
  10.  
  11. items.forEach(function(item){
  12.     var links = getElementsByTagName('a', item);
  13.     links.forEach(function(link) {
  14.         // Remove the "more" link.
  15.         if(link['attribs']['rel'] == 'nofollow') return;
  16.  
  17.         result.push({'title': link['children'][0]['data'], 'link': link['attribs']['href']});
  18.     });
  19. });
  20.  

This returns something like:

JAVASCRIPT:
  1.  
  2. {
  3.   "error": null,
  4.   "result": [
  5.     {
  6.       "title": "U.S. Discovers Est. $1 Trillion of Minerals in Afghanistan",
  7.       "link": "http://www.nytimes.com/2010/06/14/world/asia/14minerals.html"
  8.     },
  9.     // ..
  10.  

If this looks a touch familiar though... remember that the awesome YQL gives you acccess to the Web from a simple query language too.

Related Content:

  • JavaScript Object Notation for Ajax Web services
    Daniel Rubio digs into JavaScript Object Notation (JSON), the simplified data format that is gaining popularity with Ajax services and Web-based...
  • JSON (Javascript Object Notation)
    JSON (JS Object Notation) is a text-based, human-readable data interchange format used for representing simple data structures and objects in Web...
  • JSON
    JSON (JS Object Notation) is a text-based, human-readable data interchange format used for representing simple data structures and objects in Web...
  • Javascript Object Notation
    JSON (JS Object Notation) is a text-based, human-readable data interchange format used for representing simple data structures and objects in Web...
  • JavaScript mashups raise application security issues; require caution
    Mashups, which combine Web pages within a single view, may be cool, but they're inherently insecure and have access to confidential...

Posted by Dion Almaer at 5:28 am
4 Comments

+++++
5 rating from 2 votes

4 Comments »

Comments feed TrackBack URI

Sweeeeeeet. I really like the look of this. Maybe SQL-style (a la YQL) is better for querying data, but writing custom transforms in JavaScript feels a lot more flexible, and much, much more fun :)

Comment by Skilldrick — June 14, 2010

Doubt this will scale. Also, there must be a huge amount of IP law being violated here. I would not use this for any real business.

Comment by leptons — June 14, 2010

sounds a lot like what YQL does.

Comment by ChrisEsler — June 14, 2010

@leptons – It has already been exercised to 1000s req/sec per instance and the fetch queue is keyed so that 10,000 requests for an uncached feed still only result in one source URL request.

Comment by Tautologistics — June 14, 2010

Leave a comment

You must be logged in to post a comment.