我想获取 github 用户及其位置。我知道有 Github apI(GET /users) 可以为我提供用户列表。目前我正在使用PyGithub访问 github,但似乎这个库还没有实现这个 API。谁能建议我如何使用任何 github API 库获取 github 用户及其位置?
EDIT1:我更新了如下代码。但是有些我无法获得电子邮件 ID 和位置。
import github3
from datetime import datetime
def main():
g = github3.login(username="rakeshcusat", password="mypassword")
for user in g.iter_emails():
print user
current_time = datetime.now()
fhandler = open("githubuser_"+current_time.strftime("%d-%m-%y-%H:%M:%S"), "w")
for user in g.iter_all_users():
fhandler.write(" user: {0}, email: {1}, location: {2}\n".format(user, user.email, user.location))
#fhandler.flush()
fhandler.close()
if __name__ == "__main__":
main()
样本输出
user: andywatts, email: None, location:
user: mueller, email: None, location:
user: cp, email: None, location:
user: davea, email: None, location:
user: vrieskist, email: None, location: