是否有可能在Github中获得开发人员的国家名称

Is it possible to get country name of the developers in Github?

本文关键字:国家 开发 有可能 Github 是否      更新时间:2023-09-26

我需要查询来自不同国家的开发人员进行研究,但我无法获得开发人员的国家名称,如下所示:

"location": "xxx, China"

我在哪里可以得到所有的国家名称在Github?

根据@Tim Biegeleisen的建议,我向Github发出GET请求:

var theUrl = "https://api.github.com/search/users?q=location:china";
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
var reponseJson = xmlHttp.responseText;
obj = JSON.parse(reponseJson);
// Print obj 

根据GitHub API, /users返回的响应不同于单个/user请求。这样做可能是为了节省带宽,但也考虑到在显示多个值的页面中可能不需要位置信息和其他属性。

根据文档/users请求中可用的属性如下:

{
    "login": "octocat",
    "id": 1,
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "gravatar_id": "",
    "url": "https://api.github.com/users/octocat",
    "html_url": "https://github.com/octocat",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url":     "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "type": "User",
    "site_admin": false
}

如果您需要几个用户的位置数据,但数量很少,似乎最好的方法是逐页查询/users,并通过单独请求每个用户来映射到完整的用户数据。

来源:

    GitHub Users API

我在哪里可以得到所有的国家名称在Github?

来自文档:

location根据用户配置文件中显示的位置对用户进行筛选。

GitHub用户配置文件中的位置字段是可选的,并且是自由的。尽管我住在加拿大,但我现在可以把我的设置为"中国"。或者将其设置为"或"参宿四"。

根据你所做的研究类型,你可能不想依赖GitHub提供的位置数据。