lunduke-cli/examples/example.py

19 lines
456 B
Python

from lunduke.client import DiscourseClient
def main():
client = DiscourseClient()
try:
response = client.get('/posts.json')
posts = response.json()['latest_posts']
print(f"Found {len(posts)} posts")
for post in posts:
# print(post)
print(post['username'], post['topic_title'], post['excerpt'])
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()