Skip to main content

Using (Unofficial) Craigslist API for Python

Recently I've been searching for a new apartment to move into once I graduate from college, and got tired of querying Craigslist (the best site I've found for this purpose) with the same terms over and over again. So, I thought it would be useful to write a simple script to automatically send me a list of properties that match my search criteria once per week.

My complete program can be found here.

If anyone would like to create their own query, feel free to fork my program on Github for your own use.

I used this source for the Craigslist portion, and this source for the email portion.

Here's what an email looks like:



As you may have guessed, my query is for a room for rent in San Francisco, along with a few other filters. Note that my script only returns the first 5 results.  

The biggest issue I encountered while writing this program was getting an email to send to my primary Yahoo address. I eventually gave up and tried using my secondary Gmail account. However, in order for the program to send via the Gmail account, I had to enable access to all "less secure applications", and couldn't figure out how to allow just my application. So, I instead created an entire new Google account including Gmail, and used that to send emails to my primary Yahoo account. This solution works quite nicely, although I had to jump through several hoops. 

A smaller issue I had was that sometimes the length of the results I was trying to email was too long, which led me to reduce the number of results to the top 5. This was a strange issue, since sometimes 7 results was too long for it to handle, but at other times it had no problem sending 25 results. Post in the Github project page if anyone has a good explanation for this. 

After the script was working, I decided I wanted it to run on a schedule. To accomplish this, I used Automator (which comes pre-installed on Mac OS X), but there are many tools that are available. I set it to run the script every Monday at 5 pm. 

This was a small but fun and useful project to gain some experience using Python, script scheduling, and open source APIs. 









Comments

Popular posts from this blog

Reading from and Modifying a DynamoDB Table using API Gateway

In many IoT (Internet of Things) projects, it is necessary to read from and write to a database. AWS has an application called DynamoDB that is a NoSQL database, exactly what we need. While it is very simple to add/modify/delete entries in this database via the user interface, it's not so obvious how to do so via HTTP API calls. So, in this post I'll continue the AWS portion of my journey into IoT to learn how to do just that. I'll be following  this  tutorial. The first thing I encountered is I wasn't sure if I was supposed to follow the steps under "Defining APIs", or if that was just knowledge for later. Turns out, that was knowledge for later. If I had any prior experience with APIs I probably would have realized this. Basically, the "API definition"s are just a high-level plan for what you want your API requests to look like in the end. In my opinion this information should go in the "Creating the APIs" section. Moving through "Cr...

Arduino Project: Sound Alert via Twitter

For my second IoT project using Arduino MKR1000, I'll employ a sound sensor to send out alerts via Twitter when a loud sound is detected. This could have many uses, ranging from informing the inhabitants of a house that there is someone at the door, informing a car owner that their alarm is going off, or residents that a gunshot has gone off in their neighborhood. See my previous posts to learn about the setup process for the Arduino MKR1000, which is wifi-enabled without any additional extensions. I will be using the Arduino IDE to compile the code. For hardware, I'll be using the sound sensor I purchased here , as well as my Arduino, three solder-free wires, a generic breadboard, and a Kindle power cable (this probably isn't the safest way to power Arduino, but it's what I had). I'll be following this  tutorial to set up the sound detector, as well as some code from here  to utilize Twitter. The sound setup tutorial was very simple and one of the clearest wiring g...

Deep Learning - Recurrent Neural Networks (RNNs)

The latest Deep Learning topic I've been exploring is the Recurrent Neural Network (RNN). It has many use cases, including: time series extrapolation (i.e. given historical data, predict future output); object trajectory; and natural language processing (NLP). The code I wrote during this section of the course I'm taking can be found here . For my summary of RNNs, click here . Here are the notes I took while watching the lectures: RNN Theory Examples of Sequences Time Series Data (e.g. stock prices, sales rates) Sentences (i.e. natural language) Audio/Music Car Trajectories (where a car will go in a situation) [1,2,3] shifted one time step into the future would be [2,3,4] will train a network to predict y-values for this A normal neuron has input, activation function, then output A Recurrent Neuron sends output back to itself this process is called “unrolling” the neuron note that the input of each neuron is a summation from both ...