Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we get all the comments on a post ? #192

Closed
Rgwww opened this issue Jun 7, 2024 · 4 comments
Closed

How can we get all the comments on a post ? #192

Rgwww opened this issue Jun 7, 2024 · 4 comments

Comments

@Rgwww
Copy link

Rgwww commented Jun 7, 2024

I'm using your project interface to get comment data from a user's post, But when I use the app.get_tweet_comments method, getting the comments doesn't match what I get on the page.
app.get_tweet_comments("1798731573723815974", 1, cursor = 'PAAAAPAtPBwcFr7E1vGNnr32MRUCAAAYJmNvbnZlcnNhdGlvbnRocmVhZC0xNzk4NzQ3MDk4MTU1OTgzMjc0IgAA', get_hidden = True)
I read the documentation and couldn't find a way to fix it,
5e6d3ba2b29e265971f8c4217b6626a
206ef62a7e4ac089db5b15dee7364c7

@mahrtayyab
Copy link
Owner

mahrtayyab commented Jun 7, 2024

get_tweet_comments return TweetComments object, has attribute tweets which are basically the list of ConversationThread.

Iterating over this list will give you ConversationThread objects has attribute of tweets which are the list of Tweets

Iterating over ConversationThread will give you Tweet object. On this object you get text attribute to get the text.

comments = client.get_tweet_comments("1798731573723815974", 1, get_hidden=True)
for _thread in comments:
    print(_thread) # This is ConversationThread
    for comment in _thread:
        print(comment) # This is Tweet
        print(comment.text)
        print(comment.media)

@Rgwww
Copy link
Author

Rgwww commented Jun 7, 2024

get_tweet_comments返回TweetComments对象,其属性tweets基本上是 ConversationThread 的列表。

迭代此列表将为你提供ConversationThread对象tweets,该对象具有 Tweets 列表的属性

迭代 ConversationThread 将为您提供Tweet对象。在此对象上,您可以获得text属性来获取文本。

comments = client.get_tweet_comments("1798731573723815974", 1, get_hidden=True)
for _thread in comments:
    print(_thread) # This is ConversationThread
    for comment in _thread:
        print(comment) # This is Tweet
        print(comment.text)
        print(comment.media)

Just like this post, there are 3 comments in the web post of tweets[0], and only 2 comments in the iterative access. Although there is a cursor, I also tried to use the cursor to obtain the third comment, but it still couldn't be obtained. Is it that the api of this project can't support more levels of comment data

@mahrtayyab
Copy link
Owner

mahrtayyab commented Jun 7, 2024

You can call .expand() method on ConversationThread if you want to get all tweets of that thread

@Rgwww
Copy link
Author

Rgwww commented Jun 7, 2024

I'll try again. Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants