ifixit2zim is an openZIM scraper to create offline versions of iFixit website, in all its supported languages.
This scraper downloads the iFixit resources (categories, guides, ...) and puts them in a ZIM file, a clean and user friendly format for storing content for offline usage.
ifixit2zim works off a language version that you must provide via the --language argument. The list of supported languages is visible in the --help message.
docker run -v my_dir:/output ghcr.io/openzim/ifixit ifixit2zim --helpifixit2zim requires Python 3.14. The project uses Hatch as its build backend and environment manager. If you are not using the Docker image, install Hatch once (for example with pip install hatch) and use it to run from source in an isolated environment:
# running from source
hatch shell
python3 -m ifixit2zim --help
# using published version
pip3 install ifixit2zim
ifixit2zim --helpExit the Hatch shell with exit.
See pyproject.toml for the list of Python dependencies.
All contributions are welcome!
Please open an issue on Github and/or submit a Pull-request.
This project adheres to openZIM's Contribution Guidelines.
This project adheres to openZIM's Python bootstrap, conventions and policies v2.0.0.
- Don't take assigned issues. Comment if those get staled.
- If your contribution is far from trivial, open an issue to discuss it first.
- Ensure your code passes linting and formatting with Ruff and strict static type checking with Pyright.
The project uses Ruff for both linting and formatting, and Pyright in strict mode for static type checking. The same checks run in CI.
Install the pre-commit hooks after clone so they run automatically before each commit:
pre-commit installInside the Hatch shell (see Create an appropriate Python environment):
inv check-lint # ruff check
inv check-format # ruff format --check
inv check-type # pyright
inv check-all # all of the aboveAutomatic fixes are available with inv fix-lint, inv fix-format and inv fix-all.
Tests are run with:
inv test # pytest
inv coverage # pytest with coverage reportThe project uses Hatch as its build backend and environment manager. Install it once (for example with pip install hatch), then from the repository root run:
hatch shellNOTA: there are some limitations to the execution of the underlying libzim library on macOS with some known bugs. The main issue is that the full-text index is not working, so this shouldn't be a problem for quick tests. In doubt, execute the scraper in a Docker container as explained below.
First, build the Docker image (to be ran in the main folder of this repo):
docker build -t local-ifixit .
Then run the scraper with CLI arguments needed for your test (everything after ifixit2zim in the example below).
For instance, if you want to run a scrape of only the Apple_PDA category, including its guides,
in French :
mkdir -p output
docker run -it -v $(pwd)/output:/output --rm local-ifixit ifixit2zim --language fr --output /output --tmp-dir /tmp --category Apple_PDA
This will produce a ZIM in the output folder of your current directory.
To test if the ZIM produced is OK, you should run kiwix-serve, once more with Docker.
For instance, if you produced a file named ifixit_fr_selection_2022-04.zim in the
output subfolder, and port 37000 is unused on your machine, you might run:
docker run -it --rm -v $(pwd)/output:/data -p 37000:8080 ghcr.io/kiwix/kiwix-serve ifixit_fr_selection_2022-04.zimAnd then navigate to http://localhost:37000 on your favorite browser.
Once tests are complete, you may stop the Docker container by pressing Ctrl-C.
Advanced users only. This is only needed when upstream iFixit changes its
frontend. iFixit generates hashed CSS filenames, so assets must be refreshed when the
upstream site changes. Mirror the site with HTTrack into tmp/www.ifixit.com
mkdir -p tmp
httrack https://www.ifixit.com/ --path=tmp --verboseand run:
python scripts/update_assets.py --mirror-dir tmp/www.ifixit.comThe script discovers the current CSS URLs from the mirrored HTML, downloads
the CSS files and their url(...) dependencies, rewrites those URLs to local
../assets/... paths, updates the template references to the new hashed
filenames, and removes stale managed CSS files. Use --dry-run to preview the
changes.