-2

I wish to collect all tweets containing specific keywords(ex:manchesterattack,manchester) that are posted about the manchester attack from 22may. Can anyone provide me a code to collect tweets using python I have used following code:

import json
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

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,  wait_on_rate_limit_notify=True)

for tweet in tweepy.Cursor(api.search, q="manchester OR manchesterarena OR    manchesterbombing  ", lang="en").items():
    print(json.dumps(tweet._json))

I know this code return tweets from last week only. I would like to collect tweets from 22may(more than a week). How can I do that?

Jayanth
  • 329
  • 2
  • 5
  • 17

1 Answers1

0

What you are talking about is web-scrapping.

There are a couple of ways to achieve that:

  1. Twitter API - simplest
  2. Use scrapping tools like beautifulsoup, selenium etc.

Please do some research about the same. Cheers.

Sreetam Das
  • 3,226
  • 2
  • 22
  • 36