0
votes

I'm retrieving tweets via search_full_archive method. I iterate over the tweets via Cursor. I will need thousands of tweets for my research. I'm wondering how I can resume my cursor from where it's left

The code below puts the tweets chunks of a hundred gets a CSV for each 100 tweet downloaded into a CSV

analyze_obj() is a method I defined which extracts info from the responses coming from the cursor

import pandas as pd

numTweets = 100

hundred_tweets = []

tweets_dic = dict()



yuzluk_counter =0
for i, response in enumerate(tweepy.Cursor(api.search_full_archive,
                              query = "suriyeli lang:tr",
                            # environment_name = 'suriyelis',
                              label = 'suriyelis',
                                #
                           
                                 fromDate = '202201010000',
                                
                                 toDate = '202207010000').items(1000)):


    time.sleep(1)
    
    
    obj = Cursor_Object_Parser(response)

    analyzed = obj.analyze_obj()
    print(f"====>Tweet NO:{i+1}",)
    
    
    
    hundred_tweets.append(analyzed)    
    
    if (i+1) % 100 == 0:
        yuzluk_counter += 1
        tweets_dic[yuzluk_counter] = []
      
        
        
        tweets_dic[yuzluk_counter].append(hundred_tweets)

        df = pd.DataFrame(tweets_dic)
        df.to_csv(f"===>YUZLUK :{yuzluk_counter} hundred tweets")
        hundred_tweets = []