Skip to content

Commit

Permalink
add materials
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvannuenen committed Jan 5, 2023
1 parent 8ff6f1a commit ae614e7
Show file tree
Hide file tree
Showing 4 changed files with 1,527 additions and 2 deletions.
100 changes: 98 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,98 @@
# Python-Web-Scraping
D-Lab's 2 hour introduction to web scraping in Python. Learn how to scrape data from websites using the New York Times API in Python.
# D-Lab's Python Web Scraping Workshop

[![Datahub](https://img.shields.io/badge/launch-datahub-blue)](LINK)
[![Binder](http://mybinder.org/badge.svg)](LINK)

This repository contains the materials for D-Lab’s Python Web Scraping Workshop. Prior experience with Python Fundamentals and Python Data Wrangling is assumed.

## Workshop Goals

In this workshop, we cover how to scrape data from the web using Python. Web scraping involves downloading a webpage's source code and sifting through the material to extract the desired data.

Web scraping is typically only done when Web APIs are not available. Platforms like Twitter, Reddit, or The New York Times offer APIs to retrieve data. If you want to learn how to use web APIs in Python, see D-Lab's [Python Web APIs](https://github.com/dlab-berkeley/Python-Web-APIs) workshop.

Basic familiarity with Python is assumed. Understanding the material in the [Python Fundamentals](https://github.com/dlab-berkeley/Python-Fundamentals) and [Python Data Wrangling](https://github.com/dlab-berkeley/Python-Data-Wrangling) workshops highly recommended. We additionally recommend a basic understanding of HTML and CSS.

## Installation Instructions

Anaconda is a useful package management software that allows you to run Python
and Jupyter notebooks very easily. Installing Anaconda is the easiest way to
make sure you have all the necessary software to run the materials for this
workshop. Complete the following steps:

1. [Download and install Anaconda (Python 3.8
distribution)](https://www.anaconda.com/products/individual). Click
"Download" and then click 64-bit "Graphical Installer" for your current
operating system.

2. Download the [Python-Web-Scraping workshop
materials](https://github.com/dlab-berkeley/Python-Web-Scraping):

* Click the green "Code" button in the top right of the repository information.
* Click "Download Zip".
* Extract this file to a folder on your computer where you can easily access it
(we recommend Desktop).

3. Optional: if you're familiar with `git`, you can instead clone this
repository by opening a terminal and entering `git clone
git@github.com:dlab-berkeley/Python-Web-Scraping.git`.

## Is Python Not Working on Your Computer?

If you do not have Anaconda installed and the materials loaded on your workshop by the time it starts, we *strongly* recommend using the UC Berkeley Datahub to run the materials for these lessons. You can access the DataHub by clicking this button:

[![Datahub](https://img.shields.io/badge/launch-datahub-blue)](LINK)

The DataHub downloads this repository, along with any necessary packages, and allows you to run the materials in a Jupyter notebook that is stored on UC Berkeley's servers. No installation is necessary from your end - you only need an internet browser and a CalNet ID to log in. By using the DataHub, you can save your work and come back to it at any time. When you want to return to your saved work, just go straight to [DataHub](https://datahub.berkeley.edu), sign in, and you click on the `Python-Web-Scraping` folder.

If you don't have a Berkeley CalNet ID, you can still run these lessons in the cloud, by clicking this button:

[![Binder](http://mybinder.org/badge.svg)](LINK)

By using this button, however, you cannot save your work.

## Run the code

1. Open the Anaconda Navigator application. You should see the green snake logo appear on your screen. Note that this can take a few minutes to load up the first time.

2. Click the "Launch" button under "Jupyter Notebooks" and navigate through your file system to the `Python-Web-Scraping` folder you downloaded above.

3. Open the `lessons` folder, and click `01_introduction.md` to begin.

4. Press Shift + Enter (or Ctrl + Enter) to run a cell.

5. By default, the necessary packages for this workshop should already be installed. You can install them within the Jupyter notebook by running the following line in its own cell:

> ```!pip install -r requirements.txt```
Note that all of the above steps can be run from the terminal, if you're familiar with how to interact with Anaconda in that fashion. However, using Anaconda Navigator is the easiest way to get started if this is your first time working with Anaconda.

# About the UC Berkeley D-Lab

D-Lab works with Berkeley faculty, research staff, and students to advance data-intensive social science and humanities research. Our goal at D-Lab is to provide practical training, staff support, resources, and space to enable you to use R for your own research applications. Our services cater to all skill levels and no programming, statistical, or computer science backgrounds are necessary. We offer these services in the form of workshops, one-to-one consulting, and working groups that cover a variety of research topics, digital tools, and programming languages.

Visit the [D-Lab homepage](https://dlab.berkeley.edu/) to learn more about us. You can view our [calendar](https://dlab.berkeley.edu/events/calendar) for upcoming events, learn about how to utilize our [consulting](https://dlab.berkeley.edu/consulting) and [data](https://dlab.berkeley.edu/data) services, and check out upcoming [workshops](https://dlab.berkeley.edu/events/workshops).

# Other D-Lab Python Workshops

Here are other Python workshops offered by the D-Lab:

## Basic competency

* [Python Fundamentals](https://github.com/dlab-berkeley/python-fundamentals)
* [Introduction to Pandas](https://github.com/dlab-berkeley/introduction-to-pandas)
* [Geospatial Fundamentals in Python](https://github.com/dlab-berkeley/Geospatial-Fundamentals-in-Python)
* [Python Visualization](https://github.com/dlab-berkeley/Python-Data-Visualization)

## Intermediate/advanced competency

* [Computational Text Analysis in Python](https://github.com/dlab-berkeley/computational-text-analysis-spring-2019)
* [Introduction to Machine Learning in Python](https://github.com/dlab-berkeley/python-machine-learning)
* [Introduction to Artificial Neural Networks in Python](https://github.com/dlab-berkeley/ANN-Fundamentals)
* [Fairness and Bias in Machine Learning](https://github.com/dlab-berkeley/fairML)

# Contributors

* [Rochelle Terman](https://github.com/rochelleterman)
* [George McIntire](https://github.com/GeorgeMcIntire)
* [Pratik Sachdeva](https://github.com/pssachdeva)
3 changes: 3 additions & 0 deletions lessons/01_introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

The introductory slides for this workshop can be found at this [link](https://docs.google.com/presentation/d/19sE6tSRkGJcIjrStIaYeq_U1KE4Q9lY1r-qbNR7D8ro/edit?usp=sharing).
Loading

0 comments on commit ae614e7

Please sign in to comment.