1

I want to access past three months of twitter data for training a stock prediction model. I want to run a loop to get data on successive dates and I am using Tweepy in python but I don't know how to get the data on a specific date using tweepy. Also I am a bit confused about data I am currently getting. Is it the data on same day or some previous days? This is my code. How should I modify this code to get Twitter data on specific dates? I am new to coding with python. So it would help a lot if you tell me the code.

import sys
import tweepy
import matplotlib.pyplot as plt


def percentage(part, whole):
    return 100*float(part)/float(whole)

consumerKey = "aaaaaaaaaaaaaaaaaaaaaaaaa"
consumerSecret = "bbbbbbbbbbbbbbbbbbbbbbbb"
accessToken = "ccccccccccccccc"
accessTokenSecret = "ddddddddddddddddddddddddddddd"

auth = tweepy.OAuthHandler(consumerKey,consumerSecret)
auth.set_access_token(accessToken, accessTokenSecret)
api = tweepy.API(auth)

searchTerm = input("Enter keyword/hashtag to search about: ")
noOfSearchTerms = int(input("Enter how many tweets to analyze: "))

tweets = tweepy.Cursor(api.search, q = searchTerm).items(noOfSearchTerms)
Vibhav
  • 131
  • 1
  • 5
  • Possible duplicate of [tweepy get tweets among two dates](https://stackoverflow.com/questions/49731259/tweepy-get-tweets-among-two-dates) – Kevin He Sep 11 '18 at 17:52

0 Answers0