Coding for Journalists: A four-part series


Photo by Nico Cavallotto on Flickr

Update: Read the Bastards Book of Ruby

Just wanted to point web-scraping-interested visitors to a much better resource than this page: The Bastards Book of Ruby, which I wrote and have put online for your free perusal. It contains everything in this scraping guide (kept up for posterity) but with much better code and examples. For instance, I wrote five whole chapters on web-scraping:

And other chapters with specific web-scraping projects.

You can read my old scraping guide for entertainment purposes, but I wouldn’t use it for actual education.

So a little while ago, I set out to write some tutorials that would guide the non-coding-but-computer-savvy journalist through enough programming fundamentals so that he/she could write a web scraper to collect data from public websites. A “little while” turned out to be more than a month-and-a-half. I actually wrote most of it in a week and then forgot about. The timeliness of the fourth lesson, which shows how to help Pfizer in its mission to more transparent, compelled me to just publish them in incomplete form. There’s probably inconsistencies in the writing and some of the code examples, but the final code sections at the end of each tutorial do seem to execute as expected.

As the tutorials are aimed at people who aren’t experienced programming, the code is pretty verbose, pedantic, and in some cases, a little inefficient. It was my attempt to think how to make the code most readable, and I’m very welcome to editing changes.

DISCLAIMER: The code, data files, and results are meant for reference and example only. You use it at your own risk.