项目作者: peterdalle

项目描述 :
Course material for JU2602 Data journalism and visualization
高级语言: Jupyter Notebook
项目地址: git://github.com/peterdalle/mij.git
创建时间: 2017-01-29T16:52:30Z
项目社区:https://github.com/peterdalle/mij

开源协议:GNU General Public License v3.0

下载


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

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.

Exercises

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.

Projects

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