how to take all tweets in a hashtag with tweepy?

后端 未结 4 551
余生分开走
余生分开走 2021-02-04 22:53

I\'m trying to take every open tweets in a hashtag but my code does not go further than 299 tweets.

I also trying to take tweets from a specific time line like tweets on

4条回答
  •  萌比男神i
    2021-02-04 23:14

    This code worked for me.

    import tweepy
    import pandas as pd
    import os
    
    #Twitter Access
    auth = tweepy.OAuthHandler( 'xxx','xxx')
    auth.set_access_token('xxx-xxx','xxx')
    api = tweepy.API(auth,wait_on_rate_limit = True)
    
    df = pd.DataFrame(columns=['text', 'source', 'url'])
    msgs = []
    msg =[]
    
    for tweet in tweepy.Cursor(api.search, q='#bmw', rpp=100).items(10):
        msg = [tweet.text, tweet.source, tweet.source_url] 
        msg = tuple(msg)                    
        msgs.append(msg)
    
    df = pd.DataFrame(msgs)
    

提交回复
热议问题