Export and download Notion pages asynchronously
Project description
NotionExporter
Description
NotionExporter is a Python class designed to simplify the process of exporting content from Notion. It provides an interface to configure, trigger, and download content exports from Notion. The class supports exporting content in various formats (Markdown, HTML, PDF) and also allows users to choose the scope of the export (current view vs. all content).
Features
- Export content in Markdown, HTML, or PDF format.
- Configure the scope of your export: current view or all content.
- Option to include or exclude files in the export.
- Flatten the file tree structure upon export.
- Export multiple pages concurrently for faster processing.
- Monitor export progress with a progress bar.
- Automatically unpack zipped export files.
Usage
-
Download:
pip install python-notion-exporter
-
Initialization:
from python_notion_exporter import NotionExporter # Important to run in __main__ or in a method due to multiprocessing. if __name__ == "__main__": exporter = NotionExporter( token_v2="YOUR_NOTION_TOKEN", file_token="YOUR_FILE_TOKEN", pages={"Page Name": "Page ID"}, export_directory="path/to/save", flatten_export_file_tree=True, export_type=ExportType.MARKDOWN, current_view_export_type=ViewExportType.CURRENT_VIEW, include_files=True, recursive=True ) exporter.process()
You will need to get the
token_v2andfile_tokenvalues from your Notion cookies. Thepagesdictionary should contain pairs ofpage_name: page_idfor each page you want to export.
Needed Cookies
To export anything from Notion, one needs to authenticate oneself with some
Cookies (like a browser would). These cookies are called token_v2 and
file_token. They are set on all requests of a logged in user when using the
Notion web-app.
How to retrieve the Cookies?
- Go to notion.so.
- Log in with your account.
- Open the developer tools of your browser, open Application > Storage > Cookies (Chrome); Storage tab (Firefox).
- Copy the value of the Cookies called
token_v2andfile_tokenand paste them somewhere safe. - ⚠️ If you don't find
file_token, you need to have at least had exported a file manually once. - Those cookies have a 1 year validity, so you don't need to do this often.
-
Process Exports:
exporter.process()
This will initiate the export, download, and unpacking processes for the pages defined.
Requirements
- Python 3.6+
For more details or any issues, please raise a ticket or contact the maintainers.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_notion_exporter-1.0.2.tar.gz.
File metadata
- Download URL: python_notion_exporter-1.0.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cdf93e98c5b9fe87f7e46d426bd5c2683d3163f34ce4d059e80cba31c4babbc
|
|
| MD5 |
d2e1c9f3792480943216007062ad08cd
|
|
| BLAKE2b-256 |
5a41c030625338bb83ac0348197e3afe3d97f2e20c8c8bad6ec677b724599f24
|
File details
Details for the file python_notion_exporter-1.0.2-py3-none-any.whl.
File metadata
- Download URL: python_notion_exporter-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abb54742b06f65763635ecdbd210c0ebc6482d524657fa2c92a24ace94e61e3
|
|
| MD5 |
0764a02922dd2f040a5bdae5f32cae22
|
|
| BLAKE2b-256 |
47a3d29293d5eeec8668f86c4d01f11a79b14a0c017d697d720c8ddc55c68fe5
|