Reputation: 175
I'm using Tweepy Cursor to find some tweets.
for tweet in tweepy.Cursor(api.search, q='pg&e', count=100, lang='en', since=sinceDate, until=untilDate).items():
print str(tweet.created_at) + '\t' + str(tweet.text)
I have noticed that the tweet.text for many of the tweets returned mention "pg", as in the movie ranking, but don't contain my query, "pg&e" at all.
Why is this? Is there a way to get an exact match? Also, is there a way to give tweepy.Cursor a list of keywords to search for?
Thanks!
Upvotes: 2
Views: 846
Reputation: 1701
q="\"pg&e\""
will give you what you want. I guess the &
is interpreted as an AND by the API, so you have to specify that you want to search for pure text by putting extra quotation marks.
If you want to search for more keywords, using OR in your query should work, provided the query does not get rejected for being too complex. Something like q="\"pg&e\" OR other_keyword OR \"exact expression to search\""
should do the trick.
Upvotes: 4