ysearka
ysearka

Reputation: 3855

Convert dict into tweepy status

There are several thread (like here or here) concerning the ways to convert a tweepy.Status object into json or dict.

Do you have a way to do the opposite? I've scrapped a bunch of tweets and stored them as dicts in a pickle file. Now I'm trying to load them and recreate the tweepy.Status object from this dict.

The reason I'm trying to do this is because I already have several functions that take a status as input and I'd rather not have to modify them all.

Upvotes: 3

Views: 259

Answers (1)

shuuji3
shuuji3

Reputation: 1408

Tweepy.Status object is constructed through the classmethod tweepy.Status.parse(), which takes Tweepy's API object and a dictionary representing an API response JSON text.

So after you prepare an API object, you can construct Status object with a dictionary like this:

status = tweepy.Status.parse(api, tweet_dictionary)

Upvotes: 1

Related Questions