Appendix A — Companion Notebooks

Every chapter of this book has a companion Jupyter Notebook that replicates the chapter’s code and the narrative around it, so you can run, modify, and break the examples as you read. This appendix lists them all in one place.

A.1 How to Use the Notebooks

  1. Download the notebook for the chapter you are reading (links below). Right-click and “Save link as…” if your browser displays the raw file instead of downloading it.
  2. Launch Jupyter (jupyter lab or jupyter notebook) from the folder where you saved it. If you need help getting Jupyter running, see Missing Manual Chapter 16: Jupyter.
  3. Install as you go. Each chapter introduces its own libraries (pip install lines appear in the first code cells). You do not need everything installed to start.
  4. Supply your own credentials. Notebooks for the API chapters (Chapter 11 through Chapter 13) require your own API keys, set as environment variables — never pasted into cells.

The code cells ship unexecuted by design: running code, encountering errors, and debugging them is where the learning happens. Expect some cells to require your input (API keys, file paths, a chosen article or subreddit) before they run.

A.2 The Notebooks

Chapter Notebook
1. Introduction to Web Data Science ch-01-introduction.ipynb
2. Ethics, Law, and Responsible Data Collection ch-02-ethics.ipynb
3. The Post-API Age ch-03-post-api.ipynb
4. Data Formats: XML and JSON ch-04-data-formats.ipynb
5. Web Architecture and Protocols ch-05-protocols.ipynb
6. Parsing Static Web Pages ch-06-static-pages.ipynb
7. Archived Web Pages and the Wayback Machine ch-07-archives.ipynb
8. Dynamic Web Pages with Selenium ch-08-dynamic-pages.ipynb
9. Extracting Data from PDFs ch-09-pdfs.ipynb
10. Introduction to APIs: Wikipedia ch-10-wikipedia.ipynb
11. Government Data APIs ch-11-government.ipynb
12. Social and Media Platform APIs ch-12-social.ipynb
13. AI and Language Model APIs ch-13-ai-apis.ipynb
14. Automating Data Collection ch-14-automation.ipynb
15. Research Design with Web Data ch-15-research-design.ipynb

Chapter 3 is a conceptual chapter, so its notebook contains discussion and exercises rather than code — it is included for completeness (and for taking notes in).

A.3 How They Are Generated

The notebooks are generated directly from the chapter source files by tools/make_notebooks.py, which converts each chapter’s prose to Markdown cells and its code blocks to code cells. This keeps the notebooks in lockstep with the book: when a chapter changes, regenerating the notebooks (python tools/make_notebooks.py from the repository root) brings them back into sync. If you spot a discrepancy between a notebook and its chapter, trust the chapter — and please report it as an issue.