Python twitterapi:如何根据查询词和预定的时间跨度搜索tweet+;推特特征

Python twitterapi:如何根据查询词和预定的时间跨度搜索tweet+;推特特征,python,api,dataframe,twitter,twitterapi-python,Python,Api,Dataframe,Twitter,Twitterapi Python,新手程序员在这里寻求帮助。我有一个hashtags列表,我想获取2015年1月1日至2018年12月31日的所有历史推文 我尝试使用Tweepy库,但它只允许访问最后7天的推文。我还尝试使用GetOldTweets,因为它提供了访问历史推文的权限,但它不断崩溃。所以现在我已经获得了Twitter的高级API访问权限,这也让我能够访问完整的历史推文 为了使用premium API进行查询,我不能使用Tweepy库(因为它没有与premium API的链接,对吗?),我的选择是在TwitterAPI

新手程序员在这里寻求帮助。我有一个hashtags列表,我想获取2015年1月1日至2018年12月31日的所有历史推文 我尝试使用Tweepy库,但它只允许访问最后7天的推文。我还尝试使用GetOldTweets,因为它提供了访问历史推文的权限,但它不断崩溃。所以现在我已经获得了Twitter的高级API访问权限,这也让我能够访问完整的历史推文 为了使用premium API进行查询,我不能使用Tweepy库(因为它没有与premium API的链接,对吗?),我的选择是在TwitterAPI和搜索Tweets之间

1-TwitterAPI和搜索推文是否提供了有关用户名、用户位置(如果用户已被验证)、推文语言、推文来源、转发和收藏数量以及每条推文日期的信息?(就像特威比那样)。我找不到这方面的任何信息

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})
但它仍然没有达到预期的时间跨度。我不确定特征的名称是否与此库的名称匹配。

使用,您可以通过以下方式进行高级搜索请求:

from TwitterAPI import TwitterAPI
SEARCH_TERM = '#AAPL OR #FB OR #KO OR #ABT OR #PEPCO'
PRODUCT = 'fullarchive'
LABEL = 'your label'
api = TwitterAPI('consumer key', 'consumer secret', 'access token key', 'access token secret')
r = api.request('tweets/search/%s/:%s' % (PRODUCT, LABEL), {'query':SEARCH_TERM})
for item in r:
    if 'text' in item:
        print(item['text'])
        print(item['user']['name'])
        print(item['followers_count'])
        print(item['user']['location'])
        print(item['user']['verified'])
        print(item['lang'])
        print(item['user']['statuses_count'])
        print(item['source'])
        print(item['favorite_count'])
        print(item['retweet_count'])
        print(item['created_at'])
高级搜索解释了支持的请求参数。要确定日期范围,请使用以下命令:

r = api.request('tweets/search/%s/:%s' % (PRODUCT, LABEL), 
                {'query':SEARCH_TERM, 'fromDate':201501010000, 'toDate':201812310000})

非常感谢。但是,如果我不想打印,而是想将推文存储在一个数据框中,这样我就可以分析它们并将其导出到一个Excel,那该怎么办?这是一个纯粹的熊猫问题,我相信你可以通过谷歌搜索更快地找到答案。我脑子里没有这个答案。