catgirl-v / twint

MIT License
11 stars 1 forks source link

`TokenExpiryException: Rate limit exceeded` #1

Open batmanscode opened 1 year ago

batmanscode commented 1 year ago

Following up from: https://github.com/woluxwolu/twint/pull/14#issuecomment-1546783912

Any long keyword search or username scrape results in TokenExpiryException: Rate limit exceeded.

Notes:

Code sample:

import os
import twint
import datetime 
import dateutil.relativedelta

os.environ["TWITTER_AUTH_TOKEN"] = "1234"

last_month = datetime.date.today() + dateutil.relativedelta.relativedelta(weeks=-4)

search = ["btc", "bitcoin"]

# if using in jupyter, the following might be needed
# import nest_asyncio
# nest_asyncio.apply()

for item in search:
    c = twint.Config()
    c.Utc = True
    c.Full_text = True
    c.Search = item
    c.Stats = False
    c.Min_likes = 20
    c.Since = str(last_month)
    c.Popular_tweets = False
    c.Custom["tweet"] = ["id", "conversation_id", "created_at", "date", "time", "username", "user_id", "name", "tweet", "language",\
      "retweet", "quote_url", "likes_count", "retweets_count", "replies_count",\
      "mentions", "urls", "photos", "video", "hashtags", "cashtags", "reply_to", "link"]
    c.Output = "btc.csv"
    c.Store_csv = True
    c.Min_wait_time = 120

    twint.run.Search(c)