1

ここで助けを求めている初心者プログラマー。2015 年 1 月 1 日から 2018 年 12 月 31 日までのすべての履歴ツイートを取得するハッシュタグのリストがあります。

Tweepy ライブラリを使用しようとしましたが、過去 7 日間のツイートにしかアクセスできません。過去のツイートにアクセスできる GetOldTweets も使用しようとしましたが、継続的にクラッシュし続けました。これで、Twitter のプレミアム API アクセスを取得しました。これにより、過去のツイート全体にアクセスすることもできます。

プレミアム API を使用してクエリを実行するために、Tweepy ライブラリを使用することはできません (プレミアム API とのリンクがありません)。TwitterAPI と Search-Tweets のどちらかを選択します。

1- TwitterAPI と Search-Tweets は、ユーザー名、ユーザーの場所、ユーザーが確認された場合、ツイートの言語、ツイートのソース、リツイートとお気に入りの数、および各ツイートの日付に関する情報を提供しますか? (tweepyのように)。これに関する情報は見つかりませんでした。

2- クエリに期間を指定できますか?

3-これをすべて行うにはどうすればよいですか?

これは、Tweepy ライブラリの私のコードです。

hashtags = ["#AAPL","#FB","#KO","#ABT","#PEPCO",...]

df = pd.DataFrame(columns = ["Hashtag", "Tweets", "User", "User_Followers",
"User_Location", "User_Verified", "User_Lang", "User_Status", 
"User_Method", "Fav_Count", "RT_Count", "Tweet_date"])

def tweepy_df(df,tags):
    for cash in tags:
        i = len(df)+1
        for tweet in tweepy.Cursor(api.search, q= cash, since = "2015-01-01", until = "2018-12-31").items():
            print(i, end = '\r')
            df.loc[i, "Hashtag"] = cash
            df.loc[i, "Tweets"] = tweet.text
            df.loc[i, "User"] = tweet.user.name
            df.loc[i, "User_Followers"] = tweet.followers_count
            df.loc[i, "User_Location"] = tweet.user.location
            df.loc[i, "User_Verified"] = tweet.user.verified
            df.loc[i, "User_Lang"] = tweet.lang
            df.loc[i, "User_Status"] = tweet.user.statuses_count
            df.loc[i, "User_Method"] = tweet.source
            df.loc[i, "Fav_Count"] = tweet.favorite_count
            df.loc[i, "RT_Count"] = tweet.retweet_count
            df.loc[i, "Tweet_date"] = tweet.created_at
            i+=1
    return df

たとえば、Twitter API ライブラリにこれを適応させるにはどうすればよいですか?

次のようなものに適応させる必要があることを私は知っています:

for tweet in api.request('search/tweets', {'q':cash})

しかし、まだ目的のタイムスパンがありません。また、特性の名前がこのライブラリの名前と一致するかどうかはわかりません。

4

1 に答える 1