Making very specific time requests (to the second) on Twitter API, using Python Tweepy?

前端 未结 1 461
慢半拍i
慢半拍i 2020-12-03 19:34

I would like to request tweets on a specific topic (for example: \"cancer\"), using Python Tweepy. But usually its time can only be specified by a specific day, for example.

相关标签:
1条回答
  • 2020-12-03 20:08

    There is no way that I've found to specific a time using since/until.

    You can hack your way around this using since_id & max_id.

    If you can find a tweet made at around the times you want, you can restrict you search to those made after since_id and before max_id

    import tweepy
    
    consumer_key        = 'aaa'
    consumer_secret     = 'bbb'
    access_token        = 'ccc'
    access_token_secret = 'ffffd'
    
    # OAuth process, using the keys and tokens
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    
    api = tweepy.API(auth)
    
    results = api.search(q="cancer", since_id=518857118838181000, max_id=518857136202194000)
    
    for result in results:
        print result.text
    
    0 讨论(0)
提交回复
热议问题