This Python script exports all the OneNote notebooks linked to your Microsoft account to HTML files.
In order to run the script, you must first do the following:
git clone https://github.com/Danmou/onenote_export.git
http://localhost:5000/getToken
. Register.client_id
in config.yaml
.secret
in config.yaml
.pip install -r requirements.txt
.In a terminal, navigate to the directory where this script is located and run it using
python onenote_export.py
. This will start a local web server on port 5000.
In your browser navigate to http://localhost:5000 and log in to your Microsoft account.
The first time you do it, you will also have to accept that the app can read your OneNote notes.
(This does not give any third parties access to your data, as long as you don't share the client id
and secret you created on the Azure portal). After this, go back to the terminal to follow the progress.
To change the destination directory use the --outdir
option:
python onenote_export.py --outdir /path/to/outdir
To download only a subset of your notes, use the --select
option:
# Download one notebook
python onenote_export.py --select 'mynotebook'
# All matrix-related notes in the 'Linear Algebra' section of the 'Math' notebook.
python onenote_export.py --select 'math/linear algebra/*matrix*'
Select is case insensitive and supports wildcards.
The notebooks will each become a subdirectory of the output
folder, with further subdirectories
for the sections within each notebook and the pages within each section. Each page is a directory
containing the HTML file main.html
and two directories images
and attachments
(if necessary)
for the images and attachments. Any sub-pages will be subdirectories within this one.
Microsoft limits how many requests you can do within a given time period. Therefore, if you have many
notes you might eventually see messages like this in the terminal: "Too many requests, waiting 20s and
trying again." This is not a problem, but it means the entire process can take a while. Also, the login
session can expire after a while, which results in a TokenExpiredError. If this happens, simply reload
http://localhost:5000
and the script will continue (skipping the files it already downloaded).