Playing with Code — hacking a CraigsList Parser

Intro:

While watching the sky fall here on the California Coast, I decided to hack together a fun little toy for scouring some of the local Craigs List sites for things; such as Track Bikes. 🙂

The Concept:

  • Collect regions of interest list for Craigs List.
  • Execute search in each region using AJAX’ed page grabs.
  • Display parsed results in a list on the final page.

The Execution:

Using a multi-dimetional array of States, with sub-regions, hostnames were collected recorded. It looks something like this:

/*  Craigs List Stores */
$CLStores = array(
	'California' => array(
		'San Francisco' => 'http://sfbay.craigslist.org',
		'Chico' => 'http://chico.craigslist.org',
		'Sacramento' => 'http://sacramento.craigslist.org',
...
		),
	'Nevada' => array(
		'Reno' => 'http://reno.craigslist.org',
		'Elko' => 'http://elko.craigslist.org',
...
		),
...

This list is iterated upon, with each entry being passed to and AJAX worker bot. When the bot completed the page grab and parsing, the data is returned to the main document, and dynamically inserted.

foreach($CLStores as $state => $center){
        printf('
  • %s
    • ',$state); ... printf('
    • %s
      Loading...
    • ',$url,$state,$name,$id); ...

    This is all pretty basic stuff, but automation of searches is a specialty of mine, and it’s kept me gainfully employed with many contracts over the last 15 years.

    THE LINK:

    Here is THE TRACK BIKE SEARCH LINK

    Final results look like this:
    Screen Shot 2014-12-12 at 7.57.16 AM

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.