How to fix Twint to get all tweets through a specified date range?

936 Views Asked by At

Currently, I am trying to scrape the all tweets between '2015-02-01 00:00:00' and '2022-05-04 00:00:00' with word criteria from twitter using python. However, my output starts at 2022-05-03 23:58:59 and ends at 2022-04-25 13:15:04.

import twint
import nest_asyncio
import pandas as pd
nest_asyncio.apply()


c = twint.Config()
c.Store_csv = True
c.User_full = True
search = ['#Pets OR #People OR Pets OR People']
c.Search = search
c.Since = '2015-02-01 00:00:00'

c.Until = '2022-05-04 00:00:00'
c.Pandas = True
twint.run.Search(c)

df = twint.storage.panda.Tweets_df

My output looks like this with the "...." being other tweets between the date range.

OUTPUT:

1521640495159693314 2022-05-03 23:58:59 +0000 <vtv> @jeff #Pets
....
....
....
1518579343643004928 2022-04-25 13:15:04 +0000 <> #People; 
1

There are 1 best solutions below

0
On

You should try taking out the braces and putting the string with the keywords directly:

import twint
import nest_asyncio
import pandas as pd
nest_asyncio.apply()


c = twint.Config()
c.Store_csv = True
c.User_full = True
c.Search ='#Pets OR #People OR Pets OR People'
c.Since = '2015-02-01 00:00:00'

c.Until = '2022-05-04 00:00:00'
c.Pandas = True
twint.run.Search(c)

df = twint.storage.panda.Tweets_df