xxxxxxxxxx
import tweepy
import json
access_token=""
access_token_secret=""
consumer_key=""
consumer_secret=""
search_words = 'Python'
no=5
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
tweets = tweepy.Cursor(api.search_tweets,
q=search_words,
lang="en").items(no)
with open(r'twitter.txt', 'w', encoding='utf-8') as f:
for tweet in tweets:
f.write(str(tweet))
xxxxxxxxxx
Use a python library called twint this is a basic example and you can do alot more using their documentation
pip install twint
import twint
#configuration
config = twint.Config()
config.Search = "bitcoin"
config.Lang = "en"
config.Limit = 100
config.Since = "2019–04–29"
config.Until = "2020–04–29"
config.Store_json = True
config.Output = "custom_out.json"
#running search
twint.run.Search(config)