Reputation: 35
I've been doing extraction of tweets with keywords using Tweepy library for python. It's been only recently that I've noticed that my database include tweets like this: tweet example.
I searched for "ozone hole" and it returned a tweet whose text doesn't actually include "ozone hole", but "ozone hole" can be found in the title of the news, to which the author of the tweets made a reference.
Is there any way to avoid tweets like that and to search for tweets that include my keywords in the actual tweet text?
Chunk of my code that searches for tweets:
for tweet in tweepy.Cursor(api.search,
q="ozone hole",
lang="en",
#Since="2019-11-27",
#until="2019-11-14",
tweet_mode='extended').items():
Upvotes: 1
Views: 384
Reputation: 63
Try these commands for the date that you are looking for first:
unitl= datetime.date.today()
print("Today's date:", until)
since= until- datetime.timedelta(days=50) #the number isdentify the number of days that you are looking for the tweets
print(since)
Then you can use the command below to specify the keyword
tweets_list = tweepy.Cursor(...)
Upvotes: 0
Reputation: 5157
This is simply how Twitter's search works. If you search for the same query through Twitter's website, you'll see that it comes up with those same results.
Note though, that it's likely due to the query showing up in the URL itself, not in the title of that site.
Upvotes: 3