Как я могу получить полный текст из твиттера?я хочу использовать tweet_mode и full_text .. как я могу и где использовать? - PullRequest
0 голосов
/ 03 июня 2019
import tweepy

import pandas as pd                  

import matplotlib.pyplot as plt      

pd.set_option('display.unicode.east_asian_width', True)


consumerKey = 'somekey'

consumerSecret = 'somesecret'

auth = tweepy.OAuthHandler(consumer_key=consumerKey, 
    consumer_secret=consumerSecret)

api = tweepy.API(auth, wait_on_rate_limit=True)

result = api.search(q='Swiggy')

len(result)

tweet = result[0] 

for param in dir(tweet):

 if not param.startswith("_"):
        print("%s : %s\n" % (param, eval('tweet.'+param)))

results = []

for tweet in tweepy.Cursor(api.search, q='Swiggy').items(7000):
    results.append(tweet)

print(len(results))


def toDataFrame(tweets):

    DataSet = pd.DataFrame()

    DataSet['tweetID'] = [tweet.id for tweet in tweets]
    DataSet['tweetText'] = [tweet.text for tweet in tweets]
    DataSet['tweetRetweetCt'] = [tweet.retweet_count for tweet 
    in tweets]
    DataSet['tweetFavoriteCt'] = [tweet.favorite_count for tweet 
    in tweets]
    DataSet['tweetSource'] = [tweet.source for tweet in tweets]
    DataSet['tweetCreated'] = [tweet.created_at for tweet in tweets]

    DataSet['userID'] = [tweet.user.id for tweet in tweets]
    DataSet['userScreen'] = [tweet.user.screen_name for tweet 
    in tweets]
    DataSet['userName'] = [tweet.user.name for tweet in tweets]
    DataSet['userCreateDt'] = [tweet.user.created_at for tweet 
    in tweets]
    DataSet['userDesc'] = [tweet.user.description for tweet in tweets]
    DataSet['userFollowerCt'] = [tweet.user.followers_count for tweet 
    in tweets]
    DataSet['userFriendsCt'] = [tweet.user.friends_count for tweet 
    in tweets]
    DataSet['userLocation'] = [tweet.user.location for tweet in tweets]
    DataSet['userTimezone'] = [tweet.user.time_zone for tweet 
    in tweets]

    return DataSet

DataSet = toDataFrame(results)
...