Skip to content
Course material for JU2602 Data journalism and visualization
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
1 Introduction to Python
2 Web scraping and APIs
3 News robot

JU2602 Data journalism and visualization

This page contain Python code and Jupyter Notebooks for the course JU2602 Data journalism and visualization, part of the master programme in investigative journalism at JMG, Sweden.

The goal is to learn the basics of programming in general and Python in particular. No previous programming knowledge is required. The goal is to build a news robot that can scrape the web and automatically write a news article.

Please bring your computer!

Contact Peter M. Dahlgren if you have any questions.


Overview of what we'll do, apart from the lectures:

  1. Install Anaconda (choose Python version 3+) that contains Python and Jupyter Notebooks.
  2. Get familiar with Jupyter Notebooks.
  3. Do the exercises.
  4. Learn to control program flow with if-statements and for-loops.
  5. Write fuctions with def that group code into reusable blocks.
  6. End with some bigger web scraping projects: e.g., news robot.


Exercise Goal
Exercise 1: Variables Create, change and combine variables.
Exercise 2: Strings Manipulate text strings.
Exercise 3: If-statements Control program flow with if, elif and else.
Exercise 4: For-loops Use for-loops to control how lists are presented on the screen.
Exercise 5: Functions (def) Create functions that take input, change the input, and then return some new value.
Exercise 6: Error handling Understand common error messages, and how to solve them.


Project Description
Scrape Court Rulings from InfoCuria Scrape most recent judgments and opinions from InfoCuria.
Web Scraping Examples Example code for scraping Internet Movie Database, Washington Post and Wikipedia.
Model Scraper Student project that scrape body measurements from women models.
Facebook API Get Facebook status messages from any Facebook page.
BeautifulSoup Examples Example code to help you scrape HTML from web pages using BeautifulSoup.
Movie Review News Robot News robot that writes a news article based on movie data.
Earthquake News Robot News robot that writes a news article based on (fictitious) earthquake data.
Weather News Robot News robot that scrapes tomorrows weather and writes a short text complaining about how cold it is.

Jupyter Notebooks - keyboard shortcuts

  • Ctrl+Enter = run cell
  • ESC = exit out of a cell
  • Tab = autocomplete
  • a = insert cell above
  • b = insert cell below
  • dd = delete cell

Jupyter Notebook files are saved on your computer, typically in your Users folder (i.e., /Users/<username>). Read more at 28 Jupyter Notebook tips, tricks and shortcuts.

Learn more

  • In the References directory you'll find example code snippets
  • Read Learn more Python to find documentation, help and other Python resources
You can’t perform that action at this time.