Click here to Skip to main content
Licence BSD
First Posted 12 Dec 2008
Views 37,461
Downloads 827
Bookmarked 37 times

Watching Craigslist

By | 2 Jan 2009 | Article
Show automatically updated search results from Craigslist on your desktop

Overview

Craigslist is a hugely popular website with free local listings for jobs, housing, and items for sale.

Trying to buy something on Craigslist is like a flock of seagulls going after one French fry. If something good gets posted, it might be gone before you get a chance to call. So do you scan new items every morning? What if you miss a day? There are hundreds of new items that get posted each day. 

I wanted a desktop window that would show me filtered search results from Craigslist and update them periodically.

Approach

Instead of sending Craigslist a server-side query, I decided to just get the Craigslist RSS feed and filter the results on the client-side. There are two advantages of this -- server changes don't break our code and we can watch other feeds in a similar way (for example, eBay).  At first, I made a general purpose feed monitor, but it got kind of abstract and complicated and I decided a Craigslist specific application would be nicer and easier to explain.

Interface

A listview is used to display results so I can sort by column (e.g. price or date).

MainForm.jpg

For most searches, just type some keywords and press enter to load the results. Double-clicking on an item in the results list will open it in a browser. Or you can just click on the "open item" button. The Category button will open the entire list in a browser. For more advanced searches, press the Advanced button.

Advanced.jpg

For email alerts, check the send email alerts box and setup an email address.

Email.jpg

Code 

Settings are saved and restored using XML serialize.

StreamWriter sw = new StreamWriter(path);
new XmlSerializer(obj.GetType()).Serialize(sw, obj);
sw.Close(); 

You gotta love C#. And when we load and parse the RSS feed, XML does the trick again.

XmlDocument feed = new XmlDocument();
feed.Load(GetUrl());
XmlNodeList nodes = feed.GetElementsByTagName("item");

foreach (XmlNode node in nodes)
{
    // get node info
    if (Match(info)
    // add to results
} 

Similar Tools

There are other similar programs out there but none of them provide free C# code so you can extend them.

Extending This

You could easily add multiple searches and a treeview control to expand titles into descriptions.  For this article, I decided to keep those features out.  The advanced search form could easily be expanded to allow excluded keywords and any-or-all keywords.

History

  • Dec 12, 2008: Original submission
  • Dec 13, 2008: Added email alerts
  • Dec 13, 2008: Updated source and demo project 
  • Dec 29, 2008: Updated source and demo projects 

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

milkplus

Software Developer
Buzz Monkey Software
United States United States

Member

David McClurg is a game programmer from Oregon, USA. He is currently interested in C#, xna for zune, and steering behaviors. When not coding, David enjoys tennis, kayaking, and botany.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 3 PinmemberinkcolorYui17:24 24 Mar '12  
QuestionNot working right!!! PinmemberMember 78875007:03 2 May '11  
AnswerRe: Not working right!!! Pinmembermilkplus9:11 2 May '11  
GeneralRe: Not working right!!! PinmemberMember 78875009:16 2 May '11  
Question"My Ebay" Button Pinmemberardns23:37 28 Jun '10  
AnswerRe: "My Ebay" Button Pinmembermilkplus6:00 29 Jun '10  
GeneralAdding an email link in the email message PinmemberC# Friendly12:14 11 Oct '09  
GeneralRe: Adding an email link in the email message Pinmembermilkplus14:40 11 Oct '09  
Generalsearching multiple items PinmemberC# Friendly15:48 3 Oct '09  
GeneralRe: searching multiple items Pinmembermilkplus7:36 4 Oct '09  
GeneralRe: searching multiple items PinmemberC# Friendly11:59 11 Oct '09  
GeneralThe include files are for Watching eBay PinmemberJamesMMM10:45 29 Dec '08  
GeneralRe: The include files are for Watching eBay Pinmembermilkplus11:23 3 Jan '09  
GeneralRSS feed PinmemberTodd Smith10:57 13 Dec '08  
GeneralLocations Pinmemberoldpartz9:13 13 Dec '08  
GeneralRe: Locations PinmemberTodd Smith10:35 13 Dec '08  
GeneralRe: Locations Pinmemberoldpartz10:48 13 Dec '08  
GeneralRe: Locations PinmemberTodd Smith10:45 13 Dec '08  
GeneralRe: Locations Pinmemberoldpartz11:12 13 Dec '08  
GeneralVery nice article! Pinmemberthompsons7:23 13 Dec '08  
Very nice, David. I always learn something new from your coding.
Got my 5.
 
Regards,
S. Thompson

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 3 Jan 2009
Article Copyright 2008 by milkplus
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid