Notion API를 사용하여 Qiita의 최신 기사를 지정된 시간에 얻습니다.
소개
Qiita에서 걱정되는 태그의 최신 기사를 Notion에 추가하기위한 스크립트를 작성했습니다.
crontab을 사용하여 지정된 시간에 스크립트를 실행하면 최신 기사가 자동으로 Notion에 추가됩니다.
스크립트
main.py# coding: UTF-8
from notion.client import NotionClient
from notion.block import TodoBlock
import requests
import json
import datetime
# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in session on Notion.so
client = NotionClient(token_v2= <<token_v2>> )
# Replace this URL with the URL of the page you want to edit
page = client.get_block(<<block>>)
# Typescriptに関する記事を5つ取得しています
url = "https://qiita.com//api/v2/items?page=1&per_page=5&query=tag%3Atypescript"
response = requests.get(url)
jsonData = response.json()
today = datetime.date.today()
for jsonObj in jsonData:
newchild = page.children.add_new(
TodoBlock, title="【{0}】[{1}]({2})".format(today.strftime('%Y%m%d'), jsonObj["title"], jsonObj["url"]))
<<token_v2>>
는 로그인 한 페이지의 쿠키에 대한 "token_v2"항목의 값을 입력합니다.<<block>>
에 기사를 추가하려는 페이지의 URL을 입력하십시오.
이렇게하면 다음과 같은 느낌으로 기사가 추가됩니다.
Reference
이 문제에 관하여(Notion API를 사용하여 Qiita의 최신 기사를 지정된 시간에 얻습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/flat-field/items/c842a6bb5a9ca59a7304
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
main.py
# coding: UTF-8
from notion.client import NotionClient
from notion.block import TodoBlock
import requests
import json
import datetime
# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in session on Notion.so
client = NotionClient(token_v2= <<token_v2>> )
# Replace this URL with the URL of the page you want to edit
page = client.get_block(<<block>>)
# Typescriptに関する記事を5つ取得しています
url = "https://qiita.com//api/v2/items?page=1&per_page=5&query=tag%3Atypescript"
response = requests.get(url)
jsonData = response.json()
today = datetime.date.today()
for jsonObj in jsonData:
newchild = page.children.add_new(
TodoBlock, title="【{0}】[{1}]({2})".format(today.strftime('%Y%m%d'), jsonObj["title"], jsonObj["url"]))
<<token_v2>>
는 로그인 한 페이지의 쿠키에 대한 "token_v2"항목의 값을 입력합니다.<<block>>
에 기사를 추가하려는 페이지의 URL을 입력하십시오.이렇게하면 다음과 같은 느낌으로 기사가 추가됩니다.

Reference
이 문제에 관하여(Notion API를 사용하여 Qiita의 최신 기사를 지정된 시간에 얻습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/flat-field/items/c842a6bb5a9ca59a7304텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)