Now we can understand about composition of properties
, so this turn brings the title
value.
Put the result data into pages
variable.
pages = notion.search(filter={"property": "object", "value": "page"},
page_size=20)
Bring pages['results']
value, then we can find a bunch infomation. This one is information of one page.
{'title': {'id': 'title',
'title': [{'annotations': {'bold': False,
'code': False,
'color': 'default',
'italic': False,
'strikethrough': False,
'underline': False},
'href': None,
'plain_text': '기획서 작업',
'text': {'content': '기획서 작업)',
'link': None},
'type': 'text'}],
'type': 'title'}}
page
name property
is title
. if the property
set a name, it shows as set name. like as below, 생성일
(Created Date) is property's name.
'생성일': {'created_time': '2022-06-07T00:46:00.000Z',
'id': 'BQmN',
'type': 'created_time'}
If the page
is regular, find the inside value from pages['results']
and then you can find the title
name from the page.
Declare for
statement and bring pages['results']
value.
for page in pages['results']:
pprint(page['properties'])
print page['properties']
then console result as below.
{'title': {'id': 'title',
'title': [{'annotations': {'bold': False,
'code': False,
'color': 'default',
'italic': False,
'strikethrough': False,
'underline': False},
'href': None,
'plain_text': '기획서 작업',
'text': {'content': '기획서 작업)',
'link': None},
'type': 'text'}],
'type': 'title'}}
We have two ways to get title
value from the above information.
page['properties']['title']['title'][0]['plain_text']
page['properties']['title']['title'][0]['text']['content']
Choose one way of them, and bring the page
's title.
page_title_find = '기획서 작업'
for page in pages['results']:
page_title = page['properties']['title']['title'][0]['plain_text']
if page_title_find = page_title:
print('찾는 페이지가 존재합니다.')
title_id = page['id']
Launch to code like above, '기획서 작업' value input into title_id
.