Christian Heilmann

Dating for geeks – using YQL and Craigslist

Friday, April 16th, 2010 at 5:08 pm

OK, it is Friday, so let’s have some fun. If you go to Craigslist, you will find that there is quite an extensive Personals section (more filled in the US than in Europe, admittedly). It is also full of very obvious messages, so make sure you are OK to watch the links in this article in your work place.

For London, for example the URL of that is:

http://london.craigslist.co.uk/ppp/

This lists all the personals there are – regardless of what type. It also comes as an RSS feed:

http://london.craigslist.co.uk/ppp/index.rss

So, the pattern here is:

http://{location}.craigslist.co.uk/{type}/index.rss

If you want to do a search, it is slighty different:

http://{location}.craigslist.org/search/{type}?format=rss&query={query}

This is exactly what is in use in the open YQL table for craigslist.

Now, the information in craigslist is pretty extensive – and full of stuff you will not want or need.

So, you can use YQL to filter it down to what you need. Say you are a dude and you are looking for a lady you will find that a lot of the content on the results page is not for you. You can filter however down to what you are looking for with the following in YQL query:

select item.title,item.description,item.link
from craigslist.search where location=”london”
and type=”ppp” and query=”w4m”

You can see the result of this here (might contain NSFW text content).

You can also filter down to certain types. For example you can only see the women looking for men – including those who only want a casual encounter:

select item.title,item.description,item.link
from craigslist.search where location=”london”
and type in (“w4m”,”cas”) and query=”w4m”

Results of this query are available here.

You can also broaden your horizons and include different queries, like couples looking for another man:

select item.title,item.description,item.link from
craigslist.search where location=”london” and type=”cas”
and query in(“mw4m”,”w4m”)

Check out these results

Problem here is that you cannot have two sub-selects in a single query – so you need to use query.multi:

select * from query.multi where queries=’
select item.title,item.description,item.link from craigslist.search where
location=”london” and type=”w4m” and query in(“mw4m”,”w4m”);
select item.title,item.description,item.link from craigslist.search where
location=”london” and type=”cas” and query in(“mw4m”,”w4m”)

See the multi results here.

If you put this into a PHP script that gets information from a form, you can easily build a Craigslist date finder:

Craigslist Date Filter

The code is available below or directly on GitHub :

Another proof that YQL simply rocks.

Tags: , , , ,

Share on Mastodon (needs instance)

Share on Twitter

My other work: