Jean-Michel Grilly
Jean-Michel Grilly

Reputation: 13

How to fix 'Tweet' object has no attribute 'retweetCount'

Using snscrape for this example. With python 3.8 and snscrape 0.3.4

import snscrape.modules.twitter as sntwitter

keyword = '(COVID19)'

tdf = None

for i, tweet in enumerate(sntwitter.TwitterSearchScraper(keyword + ' since:2021-08-01 lang:pt').get_items()) :

    if i >50:
        break
    print(tweet.date.date())
    print(tweet.retweetCount)    
    print(tweet.renderedContent)

I get this:

AttributeError: 'Tweet' object has no attribute 'retweetCount'

Thanks for your help.

Upvotes: 1

Views: 1849

Answers (3)

Ravi kumar
Ravi kumar

Reputation: 171

The Error is with the version of snscrape you are using

Try using -

!pip install snscrape==0.4.3.20220106
            OR
!pip3 install snscrape==0.4.3.20220106

Upvotes: 0

user2864740
user2864740

Reputation: 61885

There is no Tweet.retweetCount in snscrape 0.3.4 — https://github.com/JustAnotherArchivist/snscrape/blob/v0.3.4/snscrape/modules/twitter.py

Update to the mainline, or similar appropriate version, which adds many more Tweet properties including retweetCounthttps://github.com/JustAnotherArchivist/snscrape/blob/master/snscrape/modules/twitter.py

YMMV.

Upvotes: 0

Nikolaos Chatzis
Nikolaos Chatzis

Reputation: 1979

It's a problem with snscrape's version (0.3.4). After installing the development version (that is, 0.3.5.dev138+ga6b6f3f now) your code works.

To install the development version, use the command below (copy-paste from here):

$ pip3 install git+https://github.com/JustAnotherArchivist/snscrape.git
...
$ pip3 list | grep snscrape
snscrape                          0.3.5.dev138+ga6b6f3f

Upvotes: 1

Related Questions