Twitter Search API query results don't match keyword
<p>I'm using Tweepy Cursor to find some tweets.</p>

<pre><code>for tweet in tweepy.Cursor(api.search, q='pg&amp;e', count=100, lang='en', since=sinceDate, until=untilDate).items():
    print str(tweet.created_at) + '\t' + str(tweet.text)
</code></pre>

<p>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&amp;e" at all.  </p>

<p>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?</p>

<p>Thanks!</p>

<p><code>q="\"pg&amp;e\""</code> will give you what you want. I guess the <code>&amp;</code> 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.</p>

<p>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 <code>q="\"pg&amp;e\" OR other_keyword OR \"exact expression to search\""</code> should do the trick.</p>

python api search twitter tweepy