create_dream.py 1.2 KB

12345678910111213141516171819202122232425262728
  1. import time
  2. import requests
  3. url = "https://api.notion.com/v1/pages"
  4. date_str = time.strftime("%Y-%m-%d", time.localtime())
  5. payload = {
  6. "parent": {"type": "database_id",
  7. "database_id": "de2ddb5d286e4dffacb1eb26a4e074be"},
  8. "properties": {'类型': {'id': '%3BpWm', 'type': 'select',
  9. 'select': {'id': '6bb27fbf-4938-484f-b531-4b10ff5cb718', 'name': '普通梦', 'color': 'orange'}},
  10. '方法': {'id': 'BE%7CY', 'type': 'select', 'select': {
  11. 'id': 'e53f9bb4-eb4c-4dfd-b7bf-72fdb01edb14', 'name': '无', 'color': 'red'}},
  12. '时间': {'id': 'qSdW', 'type': 'date',
  13. 'date': {'start': date_str, 'end': None, 'time_zone': None}},
  14. 'Name': {'id': 'title', 'type': 'title', 'title': [
  15. {'type': 'text', 'text': {'content': date_str, 'link': None}}]}}
  16. }
  17. headers = {
  18. "Accept": "application/json",
  19. "Notion-Version": "2022-02-22",
  20. "Content-Type": "application/json",
  21. "Authorization": "Bearer secret_PvJWhkqlZJ7PMIqqPxWDhS736TjvUbkGojyrybjyxNh"
  22. }
  23. response = requests.post(url, json=payload, headers=headers)
  24. print(response.text)