noobster
noobster

Reputation: 922

Using Tweepy to retrieve all tweets containing a particular hashtag for an account ID

Im currently getting all the tweets for a hashtag from a particular account.

By using this I can get hashtags' tweets :

   tweepy.Cursor(api.search, q='#marketing', rpp=100).items(10)

By using this I can get tweets of a parituclar Id:

   tweepy.Cursor(api.user_timeline, id="someid")

I need to combine these two to get all the tweets for a particular hashtag from an account. I've tried multiple approaches to combine the above two api calls.

Upvotes: 0

Views: 417

Answers (2)

Nihar Kashyap
Nihar Kashyap

Reputation: 40

You can directly use:

tweepy.Cursor(api.search, q="from:screen_name #hashtag")

Example:

tweepy.Cursor(api.search, q="from:someid #marketing")

This issue was raised in the tweepy github repo.
They should have added it in the documentation.

Upvotes: 0

JeffProd
JeffProd

Reputation: 3148

Just use the search API with the parameter q='#marketing from:user' to get tweets from @user containing #marketing.

Upvotes: 1

Related Questions