Why does Twints "since" & "until" not work?

610 Views Asked by At

I'm trying to get all tweets from 2018-01-01 until now from various firms. My code works, however I do not get the tweets from the time range. Sometimes I only get the tweets from today and yesterday or from mid April up to now, but not since the beginning of 2018. I've got then the message: [!] No more data! Scraping will stop now.

ticker = []
#read in csv file with company ticker in a list
with open('C:\\Users\\veron\\Desktop\\Test.csv', newline='') as inputfile:
    for row in csv.reader(inputfile):
        ticker.append(row[0])        

#Getting tweets for every ticker in the list    
    for i in ticker:
        searchstring = (f"{i} since:2018-01-01")
        c = twint.Config()
        c.Search = searchstring
        c.Lang = "en"
        c.Panda = True
        c.Custom["tweet"] = ["date", "username", "tweet"]
        c.Store_csv = True
        c.Output = f"{i}.csv"    

        twint.run.Search(c)

        df = pd. read_csv(f"{i}.csv")
        df['company'] = i
        df.to_csv(f"{i}.csv", index=False)

Does anyone had the same issues and has some tip?

1

There are 1 best solutions below

3
On

You need to add the configuration parameter Since separately. For example:

c.Since = "2018-01-01"

Similarly for Until:

c.Until = "2017-12-27"

The official documentation might be helpful.

Since (string) - Filter Tweets sent since date, works only with twint.run.Search (Example: 2017-12-27).

Until (string) - Filter Tweets sent until date, works only with twint.run.Search (Example: 2017-12-27).