chore: add cohost.py boilerplate

main
CrimsonTome 2022-10-23 20:07:34 +01:00 committed by Rowan Clark
parent cbdd6263d9
commit 807b651993
No known key found for this signature in database
GPG Key ID: F620D51904044094
1 changed files with 14 additions and 0 deletions

14
scripts/main.py Normal file
View File

@ -0,0 +1,14 @@
from cohost.models.user import User
from cohost.models.block import AttachmentBlock, MarkdownBlock
cookie = 'yourCookie'
user = User.loginWithCookie(cookie)
for project in user.editedProjects:
print(project) # Print all pages you have edit permissions for
project = user.getProject('vallerie') # will retrieve the page I have edit writes for with handle @vallerie
blocks = [
AttachmentBlock('pybug.png'), # References image file pybug.png
MarkdownBlock('**Hello from Python!**') # Example of markdown / text block
]
newPost = project.post('Title of python post!', blocks, tags=['cohost.py', 'python'])
print('Check out your post at {}'.format(newPost.url))