Reputation: 127
I'm trying to use tweepy to retrieve tweets of a particular hashtag. This is my code:
file = open('pc_week1.csv', 'a')
writer = csv.writer(file)
for tweet in tweepy.Cursor(extractor.search, q='#pyeongchang2018', count=100, lang='en', since='2017-12-01', until='2017-12-07').items():
writer.writerow([tweet.created_at, tweet.text.encode('utf-8')])
When I define the 'until' parameter, the code returns an empty dataframe. But when I DON'T define 'until', it retrieves all tweets since the date specified. The only thing is, I'm looking to get only a week's worth of data (2017-12-01~2017-12-07). Is there a way to do this?
EDIT: I tried putting in a different date for 'until' parameter:
for tweet in tweepy.Cursor(extractor.search, q='#pyeongchang2018', count=100, lang='en', since='2017-12-01', until='2017-12-15').items():
writer.writerow([tweet.created_at, tweet.text.encode('utf-8')])
And it DIDN'T return an empty df like before, but instead the results indicate that the until parameter was ignored. Here's a snippet of the results:
Date Tweet
0 2018-01-25 08:35:21 b"RT @AFP: WATCH: A dozen North Korean female ...
1 2018-01-25 08:34:19 b"RT @AFP: WATCH: A dozen North Korean female ...
2 2018-01-25 08:33:29 b'Amazing @Aerialskier what an achievement! Go...
3 2018-01-25 08:32:29 b'RT @cnni: The new police force in charge of ...
4 2018-01-25 08:32:12 b'North Korean ice hockey teams arrives in Sou...
Upvotes: 0
Views: 1093
Reputation: 11464
You are using the since
and until
parameters correctly, but the problem is that Tweepy can't return data older than 7 days.
Upvotes: 1