Cere
Cere

Reputation: 93

In depth Twitter Search API in tweepy

I wanted to search for tweets "by keyword" from a "given screen name."
Example, all tweets from "BBCNews" about "weather".

Looking into Tweepy library, I found this code:

tweepy.Cursor(api.search,
              q="weather",
              rpp=100,
              result_type="recent",
              include_entities=True,
              lang="en")

However, how am I gonna filter the tweets such that they are only from BBCNews?

Thank you in advance.

Upvotes: 1

Views: 406

Answers (1)

Efferalgan
Efferalgan

Reputation: 1701

The list of options you can use to filter the tweets you find can be found here : https://dev.twitter.com/rest/public/search

You can put them directly in your query, without caring about Tweepy. In your case, I would suggest

tweepy.Cursor(api.search,
              q="weather from:BBCNews",
              rpp=100,
              result_type="recent",
              include_entities=True,
              lang="en")

You can even add -filter:retweets to your request to get rid of the retweets.

Upvotes: 3

Related Questions