Updated October 10th, 2016.
You might not have heard but there’s a recession on. People are looking for work. For myself, I had the brilliant idea of searching the job postings on www.craigslist.org every day for Mac-related stuff, but quickly found that craigslist is sort of picky about search terms, and if you aren’t careful, you’ll miss stuff. For example, if you’re looking for AppleScript jobs, and someone’s posted one that says “Wanted: AppleScripter” you WON’T find the job if you search for “AppleScript.” Don’t ask me why– that’s just the way it is. Search for AppleScripter, and you find it. Search for AppleScript, and you don’t. (Search for “Apple” and you do. Search for “Apples” and you don’t.)Frankly, I don’t quite understand it. But, understanding it is not our job here, and while it is tempting to try to figure out why craigslist works the way it does, it would be tangential to my original goal, which is to search for jobs on craigslist. Related, but off on a tangent.
I determined that if I searched for these terms I’d find what I wanted:
- Apple
- AppleScript
- AppleScripter
- Scripter
- Mac
- Macintosh
- iPhone
That’s seven searches. Doable, but then I decided it would be nice to search craigslist in Austin, TX (austin.craigslist.org) as well as craigslist in Los Angeles, CA (losangeles.craigslist.org). Twice as many cities means twice as many searches– now up to 14, and I could see that this would not be a lot of fun after the first day or two. And remember, I wanted to do this every day.
So, what do we do when we have a repetitive task? One option: pass it to someone else. That would get it off my plate, but it’s not reasonable to expect anyone to do 14 searches perfectly every day. Mistakes get made when you have so much to do.
The correct answer for a Mac user, of course, is to make an AppleScript. Talk about practicing what you preach!
Here’s what I wrote, word for word. You can copy this script, paste it into Script Editor (you have it– look in the AppleScript folder inside your Applications folder), and run it. You can change the cities and the search terms as you wish. (You can even change it to look for things other than jobs. I can help you with that.)
The script:
— AppleScript by Christian Boyce, to search craigslist.org for jobs
— Original version written May 21st, 2009.
— May be copied and modified as desired. Let me know if you find it handy.
— Write me at macman@christianboyce.com
—
set the_cities to {"losangeles", "austin"}
set the_search_terms to {"apple", "applescript", "applescripter", "scripter", "mac", "macintosh", "iPhone"}
—
tell application "Safari"
activate
repeat with a_city in the_cities
repeat with a_search_term in the_search_terms
make new document at end of documents
— the next two lines belong together– from "set" to "a_search_term"
set URL of document 1 to "http://" & a_city & ".craigslist.org/search/jjj?query=" & a_search_term
end repeat
end repeat
end tell
You can almost read it like a book. The gray italicized stuff is just comments, notes for us so that down the road we remember what we were doing. We set up a list of cities, using the terms craigslist uses in its URLs. Then we set up a list of search terms. Then, starting with the first city, we tell Safari to open a new window (document) and put a certain URL into it. (The first URL is “http://losangeles.craigslist.org/search/jjj?query=apple”.) And then we make another window for the next search term, then another etc. until we’ve done all the search terms for the first city. Then we go back and do it all for the second city (in this case, Austin).
The whole thing takes about 8 seconds to load 14 pages here. Plenty fast– a lot faster than doing it by hand, and of course there are no typos.
The nice thing about this script is it’s easily modified. If I decide to search San Francisco, or Dallas, or San Diego, or Sacramento, all I have to do is add those cities to my city list (“the_cities”). If I want to search for other kinds of jobs (“snake handler”, “exotic dancer”) I can easily add those to my search terms (“the_search_terms”).
It’s going to save us a lot of time over here. Copy it and modify it for your own purposes (and if we apply for the same job remember who wrote the script for you).
Copyright 2008-2024 Christian Boyce. All rights reserved.
Did this article help you?
Maybe you'd like to contribute to theChristian Boyce coffee fund.
Want some some quick iPhone how-tos?
Visit me at iPhoneinaminute.com.
Looking for quick tips about Macs?
See my One-Minute Macman website!
Please Leave a Comment