Search code examples
twitter

Is it possible to search twitter users with many keywords


I can search a tweet with many keywords, but when I try to search users with many keywords, it just does not return any thing (for loop is skipped)

searchQuery = 'tokyo' OR 'osaka' OR 'london'
for target in tweepy.Cursor(api.search_users,q=searchQuery).items(1000) :

So it is impossible to search users with many keywords?


Solution

  • According to the Twitter Search API, the q parameter takes a max of 500 characters, which limits the number of parameters. The docs also state that q has a complexity limit, which is undefined. What you can do is experiment with the number of parameters to get a general idea of where the complexity limit is for your use case. This won't guarantee not hitting the limit, but could lead to a mitigation technique to avoid the problem.

    Another thing is to double-check that your problem isn't compounded by rate limits, which I discuss in another SO post, How rate limit works in twitter in search API.

    Also, the Standard Search API only goes back 7 days and is limited to relevance, which is undefined.