I trying to retrieve tweets over a list of users, however in the snscrape function this argument is inside quotes, which makes the username to be taken as a fixed input
import snscrape.modules.twitter as sntwitter
tweets_list1 = []
users_name = [{'username':'@bbcmundo'},{'username':'@nytimes'}]
for i,tweet in enumerate(sntwitter.TwitterSearchScraper('from:{}').get_items().format(username)):
if i>100:
break
tweets_list1.append([tweet.date, tweet.id, tweet.content, tweet.url,\
tweet.user.username, tweet.user.followersCount,tweet.replyCount,\
tweet.retweetCount, tweet.likeCount, tweet.quoteCount, tweet.lang,\
tweet.outlinks, tweet.media, tweet.retweetedTweet, tweet.quotedTweet,\
tweet.inReplyToTweetId, tweet.inReplyToUser, tweet.mentionedUsers,\
tweet.coordinates, tweet.place, tweet.hashtags, tweet.cashtags])
As output Python get:
`AttributeError: 'generator' object has no attribute 'format'
This code works fine replacing the curly braces with the username and deleting the .format attribute. If you want replicate this code be sure install snscrape library using:
pip install git+https://github.com/JustAnotherArchivist/snscrape.git
I really appreciate any guidance you can give me.