Reputation: 293
My problem is that while streaming tweets with tweepy, retweet_count
is always 0.
Here is my code:
tweet = utf8mb4.sub(u'', tweet.json)
tweet = json.loads(tweet)
print tweet
q = u'INSERT INTO url VALUES (%s, %s);'
for i in tweet['entities']['urls']:
try:
insert = (tweet['id'],
util.unshorten(i['expanded_url']))
c.execute(q, insert)
except IOError:
continue
tweet['created_at'] = util.isoformat(tweet['created_at'])
tweet['text'] = htmlparser.unescape(tweet['text'])
tweet['source'] = util.strip_tags(tweet['source'])
q = u'INSERT IGNORE INTO status VALUES (%s, %s, %s, %s, %s,%s);'
insert = (tweet['id'],
tweet['user']['id'],
tweet['created_at'],
tweet['text'],
tweet['source'],
tweet['retweet_count'])
c.execute(q, insert)
Upvotes: 0
Views: 1891
Reputation: 1372
This is quite normal as it is expected when you are using streaming api endpoint, its because you receive the tweets as they are posted live on twitter platform, by the time you receive the tweet no other user had a chance to retweet it so retweet_count will always be 0. If you want to find out the retweet_count you have to refetch this particular tweet some time later using the rest api then you can see the retweet_count will contain the number of retweets happened till this particular point in time.
Upvotes: 3
Reputation: 293
There is a retweeted_status in json file, and that contains the real retweet_count
Upvotes: 0