我正在构建一个可获取问题并提取超过1K github存储库请求的应用程序,就像这样。
$ curl -i "https://api.github.com/repos/user/repo/issues?state=closed"
Run Code Online (Sandbox Code Playgroud)
我的问题是,在最初的60次迭代之后,我遇到了速率限制错误:
{
"message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
"documentation_url": "https://developer.github.com/v3/#rate-limiting"
}
Run Code Online (Sandbox Code Playgroud)
该文件说,我可以使用高达5000个请求验证这一点我注册了一个OAuth并获得Client ID和Client Secret令牌
https://api.github.com/repos/{repo.name}/issues?client_id=...&client_secret=...
速率限制仍然仅在大约60个请求后才会显示。
我有以这种格式返回日期的网址
url_date = "2015-01-12T08:43:02Z"
Run Code Online (Sandbox Code Playgroud)
我不知道为什么有字符串,它会更容易得到它,因为"2015-01-1208:43:02"它可以更简单地解析使用
datetime.datetime.strptime(url_date , '%Y-%m-%d')
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我试过了
%Y-%m-%d
%Y-%m-%d-%H-%M-%S
%Y-%m-%d-%H-%M-%S-%Z
Run Code Online (Sandbox Code Playgroud)
但我一直得到像"时间数据2015-01-12T08:43:02Z不匹配......"的错误
我从网址获取API,例如: http://api.example.com/search/foo/bar
使用这个简单的代码。
import json
url = "http://api.example.com/search/foo/bar"
result = json.loads(url) # result is now a dict
print result['name']
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误。
Traceback (most recent call last):
File "index.py", line 6, in <module>
result = json.loads(url);
File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 383, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Run Code Online (Sandbox Code Playgroud)