twitter-api-client
twitter-api-client copied to clipboard
[Enhancement] Retrieve an author's thread
My goal is to retrieve threads based on the first tweet's id
I've managed to do so by combining scraper.tweets_by_id([my_tweet_id])
and search.run()
with the query conversation_id:{id} from:{username} to:{username} filter:replies
. But search is quite rate-limited.
So do you think there is a way to use scraper.tweets_details([id])
and get it to stop when the author is not the author of the first retrieved Tweet anymore? And is the rate limit better on this one?
I'm willing to write a PR but need some pointers on getting started
Much needed, @yleflour did you found a better solution?
I made it work using tweet details method, but I think if there exist a method itself to get scrape thread that would be even better
tweet_details = scraper.tweets_details([1716635331393380619])
for entry in tweet_details[0]["data"]["threaded_conversation_with_injections_v2"]["instructions"][0]["entries"]:
content = entry["content"]
if content["entryType"] == "TimelineTimelineItem":
legacy_obj = content["itemContent"]["tweet_results"]["result"]["tweet"]["legacy"]
print("### tweet id ", legacy_obj["id_str"])
print(legacy_obj["full_text"])
print()
else:
for entity in content["items"]:
legacy_obj = entity["item"]["itemContent"]["tweet_results"]["result"]["legacy"]
print("### tweet id ", legacy_obj["id_str"])
print(legacy_obj["full_text"])
print()