A Node.js script to automatically download and extract D3.js examples and visualizations from ObservableHQ. This tool helps you easily obtain local copies of popular D3.js notebooks for learning, reference, or offline use.
- Automated downloading of ObservableHQ notebooks
- Progress bar visualization for download status
- Automatic extraction of downloaded notebooks
- Built-in delay between requests to respect server limits
- Support for multiple notebook downloads in a single run
- Colorful console output for better visibility
- Error handling and retry mechanisms
- Node.js (v14 or higher)
- npm (Node Package Manager)
You can install this package either through npm or by cloning the repository.
npm install -g d3-observable-downloader
- Clone this repository:
git clone https://github.com/codeblackwell/d3-observable-downloader.git
cd d3-observable-downloader
- Install dependencies:
npm install
- puppeteer - For web scraping and automation
- cli-progress - For progress bar visualization
- chalk - For colored console output
- tar - For handling .tgz files
You can run the script in two ways:
- If installed globally via npm:
d3-observable-download
- If installed manually:
npm start
The script will:
- Create a
resources
directory if it doesn't exist - Download specified ObservableHQ notebooks
- Extract the downloaded notebooks
- Show progress for each operation
The script includes a curated list of popular D3.js notebooks, including:
- Animated Treemap
- Temporal Force-Directed Graph
- Connected Scatterplot
- The Wealth & Health of Nations
- Bar Chart Race
- Various visualization examples (treemaps, sunbursts, force-directed graphs, etc.)
D3_ObservableHQ/
├── observables_scraper # Main script
├── resources/ # Downloaded notebooks
└── README.md # This file
The script includes a configuration object with the following defaults:
- Request delay: 1000ms
- Base URL: https://observablehq.com
- Downloads directory: User's system downloads folder
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
This project is open source and available under the MIT License.
- ObservableHQ for providing the amazing D3.js examples
- D3.js community for creating these visualizations