Listings-Like-This

Listings-Like-This is a very simple demonstration showing how the hListing pattern deployed on Kelkoo can be used in mash ups.

hListing provides a good base for shopping sites, identifying the item for sale, the seller and retail price. All offers on Kelkoo's new pages use hListing; search results, merchant listings, categories and brand pages. Any of those pages can be used as a data source for a product listing mash-up.

The Hack

Listings-Like-This is a two part hack. The first is a rough-and-ready hListing profile for Drew McLellan's excellent hKit microformat parser, and a quick web service to transform a web page into JSON. That provides the means to consume Kelkoo pages programatically.

You can play with the transformer for hlisting and hcard microformats. The URL is http://hack.ben-ward.co.uk/parse/proxy.php and the following arguments should be somewhat self-explanatory:

profile
Required: The microformat to parse. Either hcard or hlisting
output
Required: The output format from the transformer, either text for print_r object dump of the parsed structure, or json for use in your mash-up.
url
Required: The datasource URL to parse.
callback
output=JSON only: A callback function to wrap the JSON array with.

So for example, this URL displays the object structure for a Kelkoo search results page: http://hack.ben-ward.co.uk/parse/proxy.php?profile=hlisting&output=text&url=http://shopping.kelkoo.co.uk/ctl/do/search?siteSearchQuery=450D+Canon

Part two of the Listings-Like-This hack is a quick demo of the JSON data being consumed on a blog, in a ‘related products’ widget.

Blog widget demo

The demo works as follows:

  1. Add a static widget to the page (in this case text recommending Kelkoo as a place to find products related to the entry; imagine an affiliate scheme arrangement).
  2. The widget reads all the tags from the page, and uses those as search terms for a Kelkoo search.
  3. A Kelkoo search URL is constructed and passed through the transformer to produce a JSON structure of the results.
  4. The widget overrides the static base content of the widget, replacing it with a list of the first five search results (by default ordered by popularity, so reasonably relevant).

One caveat with Kelkoo is that to prevent click-fraud there are not real URLs for individual offers, so the widget falls back to linking each search result to the search result page itself. If we manage to fix that bug, the widget will automatically start linking directly.