Baby Steps in Data Journalism

Starting from zero, this Tumblr provides tools, links and how-to information for people just beginning to explore data journalism.
Posts tagged "library"

Three.js is a JavaScript library for making and animating 3D objects in the browser. LearningThree.js is a tutorial blog about Three.js.

Watch this video to learn more! 

Which Way Should I Use?

Short answer: always use import.

Modest Maps is a small, extensible, and free library for designers and developers who want to use interactive maps in their own projects. It provides a core set of features in a tight, clean package with plenty of hooks for additional functionality.

It’s available for JavaScript, Python, PHP, ActionScript 3, and more.

Scraping a Web page

So I’m on page 31 of Nathan’s book, and finally, everything is working. Ah!

Click the image above to see it full-size and readable. That is what the Python library BeautifulSoup can do for you. That is how Web pages are scraped.

But I realized something. The power of those few lines is obvious to me because I know HTML. I know what img and src mean. A lot of journalists have never learned HTML, so they would probably look at that and say, “Huh?”

Memo to self: Before teaching how to scrape, I must ensure that students know basic HTML.

There are lots of pages around the Web where someone is asking why he/she got this error message. There are two reasons (if your case is like mine):

  1. You installed the latest version of BeautifulSoup (4.x), which is okay.
  2. You used this command: from BeautifulSoup import BeautifulSoup (not okay).

The fix is simple (assuming you have installed BeautifulSoup correctly): Just use the new command, which applies to BeautifulSoup version 4.x (but not the older versions):

from bs4 import BeautifulSoup

I found the answer where I find so many good answers to code questions: Stack Overflow.

> The answer.

On page 30, just after he tells us to download Python if we don’t already have it, Nathan says we should download and install Beautiful Soup, a Python library whose mission in life is to pull data out of HTML and XML files — commonly known as “scraping.”

The current release is Beautiful Soup 4.0.3 (April 3, 2012). You can install it with pip install beautifulsoup4 or easy_install beautifulsoup4. It’s also available as the python-beautifulsoup4 package in recent versions of Debian and Ubuntu.

Beautiful Soup 4 works on both Python 2 (2.7+) and Python 3.

Downloading was easy. My first hurdle was to uncompress/expand the compressed file that I had downloaded.

NOTE: Don’t bother downloading the file. Just keep reading.

Read More