Skip to content

Commit

Permalink
Merge pull request #6 from niuware/development
Browse files Browse the repository at this point in the history
Add 'comments' example
  • Loading branch information
niuware authored Nov 15, 2019
2 parents 5c756a3 + 018c9e2 commit 9b57ae4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/get_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from sys import argv
from context import Instpector, endpoints

def get_timeline(**options):
instpector = Instpector()
if not instpector.login(user=options.get("user"), password=options.get("password")):
return

timeline = endpoints.factory.create("timeline", instpector)
comments = endpoints.factory.create("comments", instpector)

for post in timeline.of_user(options.get("target_user_id")):
print(post)
for comment in comments.of_post(post):
print(comment)
### Like a comment:
# comments.like(comment)
### Unlike a comment:
# comments.unlike(comment)
if comment.thread_count > 0:
for thread_comment in comments.of_comment(comment):
print(thread_comment)

instpector.logout()

if __name__ == '__main__':
if len(argv) < 6:
print((
"Missing arguments: "
"--user {user} "
"--password {password} "
"--target_user_id {user_id}"
))
exit(1)
get_timeline(
user=argv[2],
password=argv[4],
target_user_id=argv[6]
)

0 comments on commit 9b57ae4

Please sign in to comment.