1234567891011121314151617181920212223242526272829 |
- from notion_client import Client
- # 首先设置环境变量 NOTION_API_SECRET,该值为你的 Notion API 密钥
- notion = Client(auth="secret_PvJWhkqlZJ7PMIqqPxWDhS736TjvUbkGojyrybjyxNh")
- # 填写你要创建文档的数据库 ID 和文档名称
- database_id = "0e213716cac641189939bf5c84662803"
- document_title = "YOUR_DOCUMENT_TITLE"
- try:
- # 在指定数据库中创建一个空白文档
- new_page = {
- "Name": {
- "title": [
- {
- "text": {
- "content": document_title
- }
- }]
- }
- }
- created_page = notion.pages.create(parent={"database_id": database_id}, properties=new_page)
- # 获取文档的公开 URL
- page_url = created_page['url']
- print("The URL of the created page is: ", page_url)
- except Exception as e:
- print("Encountered an error:", e)
|