-3

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.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
Masum Billah
  • 133
  • 1
  • 4
  • 13
  • did you mean to extract from hashtag, or the keyword inside the tweet? – user2906838 Jul 24 '18 at 04:24
  • I mean hashtag. I think I am having issue from here tweets = extractor.user_timeline(screen_name="-------------", count=2000) print("Number of tweets extracted: {}.\n".format(len(tweets))) This code is basically extracting from ID . I want to extract from hashtag . Cheers – Masum Billah Jul 24 '18 at 05:18
  • Please check this: https://stackoverflow.com/questions/44948628/how-to-take-all-tweets-in-a-hashtag-with-tweepy This may help you. – user2906838 Jul 24 '18 at 05:30
  • Thanks mate , My current code works fine with any Hash tag Except " #LetsTaxThis" . What could be the issue do you think. Cheers – Masum Billah Jul 25 '18 at 10:47
  • You have space before the hash `" #LetsTaxThis"`. I'm not sure if that's causing the problem. `"#LetsTaxThis"`, can you try doing this instead. – user2906838 Jul 25 '18 at 11:02

1 Answers1

1

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)
ysearka
  • 3,805
  • 5
  • 20
  • 41