taspinar / twitterscraper

Scrape Twitter for Tweets
MIT License
2.39k stars 581 forks source link

Impossible to have other data than tweet #283

Closed Totogaga2 closed 4 years ago

Totogaga2 commented 4 years ago

Here is my code and when I run it I can only obtain the tweets but no information like: #of likes, RT, username,... Thanks in advance

from twitterscraper import query_tweets
import datetime as dt
import pandas as pd
from twitterscraper import query_tweets_from_user
import json

start_date=dt.date(2019,4,10)
end_date=dt.date(2019,4,15)
limit=100
lang='english'

with open('output.csv', 'w+') as file:
    for tweet in query_tweets('Tiger King',begindate=start_date,enddate=end_date,limit=limit,lang=lang):
        file.write(str(tweet.text.encode('utf-8'))+'\n')
file.close()

twitterscraper

lapp0 commented 4 years ago

you are using tweet.text. If you observe the Tweet class in tweet.py, it has the attribute Tweet.likes, Tweet.retweets, etc. Please check out that file to see what attributes are available for your consumption.