Processing
 

Using python, how to use collect tweets (using tweepy) between two dates?

25/08/2016 03:28#1

Joined at: 5 months ago

Post: 2

Thank: 0

Thanked: 0

How can i use python and tweepy in order to collect tweets from twitter that are between two given dates?

is there a way to pass from...until... values to the search api?


Note: I need to be able to search back but WITHOUT limitation to a specific user

i am using python and I know that the code should be something like this but i need help to make it work.

      auth = tweepy.OAuthHandler(consumer_key, consumer_secret)     auth.set_access_token(access_token_key, access_token_secret)     api = tweepy.API(auth)      collection = []     for tweet in tweepy.Cursor(api.search, ???????).items():         collection[tweet.id] = tweet._json  
27/08/2016 20:22Top#2

Joined at: 5 months ago

Post: 2

Thank: 0

Thanked: 0

After long hours of investigations and stabilization i can gladly share my findings.

  • search by geocode: pass the geocode parameter in the 'q' parameter in this format: geocode:"37.781157,-122.398720,500mi" , the double quotes are important. notice that the parameter near is not supported anymore by this api. The geocode gives more flexibility

  • search by timeline: use the parameters "since" and "until" in the following format: "since:2016-08-01 until:2016-08-02"

there is one more important note... twitter don't allow queries with too old dates. I am not sure but i think they give only 10-14 days back. So you cannot query this way for tweets of last month.

===================================

for status in tweepy.Cursor(api.search,                        q='geocode:"37.781157,-122.398720,1mi" since:2016-08-01 until:2016-08-02 include:retweets',                        result_type='recent',                        include_entities=True,                        monitor_rate_limit=False,                         wait_on_rate_limit=False).items(300):     tweet_id = status.id     tweet_json = status._json 
25/08/2016 05:34Top#3

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

You have to use max_id parameters as described in twitter documentation

tweepy is a wrapper around twitter API so you should be able to use this parameter.

As per geolocation, take look at The Search API: Tweets by Place. It uses same search API, with customized keys.

Similar articles

How do twitter giveaways work?

9 months ago - Reply: 2 - Views: 130

How may I get genuine followers on Twitter?

3 years ago - Reply: 33 - Views: 1,832

Login to Twitter sometime fail

7 months ago - Reply: 1 - Views: 27

Twitter doesn't accept PHP's cURL, but Linux'

1 year ago - Reply: 2 - Views: 92

Twitter OAuth on iOS

6 months ago - Reply: 1 - Views: 96

why am i getting an error on .verifyCredentials()

6 months ago - Reply: 1 - Views: 37

TwitteR setup_twitter_oauth() gives an error

6 months ago - Reply: 1 - Views: 31

Tweepy - Getting the author of a retweeted tweet

6 months ago - Reply: 0 - Views: 7

Retrieving data from twitter with JavaScript

6 months ago - Reply: 0 - Views: 4

Combined social media feed returning the wrong data

6 months ago - Reply: 0 - Views: 3

Django and Twitter request_token

6 months ago - Reply: 0 - Views: 3

Python HMAC hashed value encoding to base64

6 months ago - Reply: 1 - Views: 35

At the rate symbol in facebook

6 months ago - Reply: 0 - Views: 3

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re