This README is a guide for teachers who are using a series of four videos to teach students how to write a web scraping script in Python. The script uses the requests
and BeautifulSoup
libraries to scrape content from any website.
The course is divided into four videos:
-
Video 0: Python Web Scraping Demo - This video introduces the series and guides the students through building a web scraper to gather information from a Wikipedia page. It covers the installation of necessary libraries like
requests
andBeautifulSoup4
, and demonstrates how to create a scraper that efficiently retrieves data. -
Video 1: Python Web Scraping Essentials: Requests and BeautifulSoup Explained - This video delves deeper into the fundamentals of web scraping with Python. It explores the key components: importing
requests
for fetching web pages and understandingBeautifulSoup
, the powerhouse for parsing HTML and XML documents. It also covers the basics of HTML as a protocol for internet file access and howBeautifulSoup
streamlines web content manipulation. -
Video 2: Parsing HTML Sections with BeautifulSoup - This video explores the process of parsing HTML sections using
BeautifulSoup
. It shows how to sethtmlText
equal to theresponse.text
from your web request and segment the content into sections using the 'html.parser'. It also demonstrates how to print the parsed HTML withBeautifulSoup
, enabling students to extract specific elements like paragraphs from the webpage. -
Video 3: Handling Errors and User Input in Your Web Scraper - This video explores how to tackle error handling and user input integration to enhance your web scraper program. It teaches how to define functions for setting the URL and specifying the number of lines for parsing, utilizing interactive prompts for user input. It also covers error handling techniques, including how to gracefully handle 404 errors, and how to incorporate conditional statements and while loops into the code for robustness.
Ensure that students have Python installed on their computers. They should also have a text editor or Integrated Development Environment (IDE) where they can write and run Python code.
Guide the students through each video, pausing after each major concept to facilitate discussions and answer questions. Encourage students to write the code as they go along, so they can learn by doing.
Assign exercises that allow students to practice what they've learned. For example, they could write a web scraper for a different website, or modify the existing script to extract different types of data.
Remember, teaching programming is not just about the code. It's also about problem-solving and thinking logically. Encourage students to experiment with the code and explore different solutions. Happy teaching! 😊