Export and download Notion pages asynchronously
MIT License
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).
Download:
pip install python-notion-exporter
Initialization:
from python_notion_exporter import NotionExporter
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_v2
and file_token
values from your Notion cookies. The pages
dictionary should contain pairs of page_name: page_id
for each page you want to export.
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.
token_v2
and file_token
and pastefile_token
, you need to have at least had exported a file manually once.Process Exports:
exporter.process()
This will initiate the export, download, and unpacking processes for the pages defined.
For more details or any issues, please raise a ticket or contact the maintainers.