Search code examples
python-3.xapitwitterdata-science

How can I extract tweets using tweepy


My Questions is If I want to get Tweets based on a specific Keyword , What I should have done or How I can get it .

i use latest Python and anaconda Distribution I use Jupyter Notebook This is what I wrote

This is my code

My Questions is If I want to get Tweets based on a specific Keyword , What I should have done or How I can get it.


Solution

  • If you don't care about the user id, you don't need to use api.user_timeline as it is user based. You should try to use the api search:

    query = "#WhateverHashtagIWant"
    my_tweet_list = []
    for page in tweepy.Cursor(api.search,q=query).pages():
        my_tweet_list.extend(page)