首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Twython利率限制

Twython利率限制
EN

Stack Overflow用户
提问于 2013-11-05 01:49:37
回答 1查看 2.1K关注 0票数 0

我得到了一个'TwythonRateLimitError‘,并希望确保我没有搞砸我的帐户。我刚开始使用Twitter。我如何检查以确保我没有超过我的查询限制?我读到每小时有150个查询.如果我这么做了怎么办?在我的代码中,我是否面临这样的风险?还是只针对特定的命令?

我不是在建立一个应用程序,我只是想得到一个特定的例子推特(随机的一组类似的用户群(7500到10000追随者)。到目前为止,我的代码如下。我将保存成功的命中文件,但我正在等待,以确保这是必要的。

代码语言:javascript
复制
from twython import Twython, TwythonError, TwythonRateLimitError
from random import randint

APP_KEY = 'redacted'
APP_SECRET = 'redacted'
ACCESS_TOKEN = 'redacted'

twitter = Twython(APP_KEY, APP_SECRET, oauth_version=2)
ACCESS_TOKEN = twitter.obtain_access_token()

twitter = Twython(APP_KEY,access_token=ACCESS_TOKEN)

print "hello twitterQuery\n"

count = 0
step = 0
isError = 0
try:
    #new account i made today to set upper bound on userID
    maxID = twitter.show_user(screen_name="query_test")['id']
except TwythonRateLimitError:
    isError = 1
ids = [0,0,0,0,0,0,0,0,0,0]
if isError == 0 and step <= 150:
    while count < 10:
        step = step +1
        randomID = randint(1,maxID)
        isMissing = 0
        print str(step) + " " + str(randomID)
        try:
            randomUserData = twitter.show_user(user_id=randomID)
        except TwythonError:
            isMissing = 1;
        if isMissing == 0:
            followers = randomUserData['followers_count']
            if followers >= 7500 and followers <= 10000:
                print "ID: " + str(randomID) +", followers: "+ str(followers)
                ids[count] = randomID
                count = count+1

print "\ndone"
for each id in ids:
    print id
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-05 03:26:00

若要查看当前的利率限制状态,请传入应用程序令牌并将GET请求发送到

status.json

并询问答复。

有关进一步的上下文,请参见此页

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19780666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档