Reputation: 13
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
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
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 retweetCount
— https://github.com/JustAnotherArchivist/snscrape/blob/master/snscrape/modules/twitter.py
YMMV.
Upvotes: 0
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