'Tweepy: how to scrape hashtags

I am scraping several twitter profiles profiles with the V1.1 api, and it works all fine and dandy using the method

api.user_timeline(screen_name = profile, count = n, tweet_mode = "extended", exclude_replies = True)

How can I scrape hashtags? and I don't want to scrape them specifically from given profiles. For instance I'd like to scrape all tweets that have a given hashtag form a specific date onward or the last N tweets with that hashtag regardless of the profile tweeting it.

Any tips? Thanks!



Solution 1:[1]

Did you try the api.search() method ?

You can use it to get the tweets containing some hashtag:

for tweet in tweepy.Cursor(api.search, q='#myHashtag').items():
    print(tweet)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mickael Martinez