Twitter每15分钟限制一次180个电话

时间:2017-07-20 09:13:14

标签: python json twitter

Python努力阅读许多JSON文件?

我正在编写一个简短的脚本来检查哪些5个字母的Twitter句柄可用,基本上是5个循环,然后使用Twitter API检查它是否可用。

在for循环中间我有两行:

response = requests.get("https://twitter.com/users/username_available?username=" + user)
print user, str(response.json()["valid"])

它运行了一点点,并且在某些时候决定它再也无法读取JSON文件,现在当我尝试运行它时会立即停止并出现同样的错误:

  File "check.py", line 25, in <module>
    main()
  File "check.py", line 16, in main
    print user, str(response.json()["valid"])
  File "/Library/Python/2.7/site-packages/requests/models.py", line 886, in json
    return complexjson.loads(self.text, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

我想到的唯一合乎逻辑的答案是我的计算机无法处理如此多的JSON请求,但我想知道是否有人知道如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

经过多分钟的困惑后解决了这个问题。

Twitter的速率限制为每15分钟180次。 https://dev.twitter.com/rest/public/rate-limiting