我可以用这个获取存储库观星者计数。
curl https://api.github.com/repos/mottosso/be/stargazers
Run Code Online (Sandbox Code Playgroud)
但我怎样才能获得吉斯特的观星者呢?
例如
curl https://api.github.com/gists/mottosso/9b25f547d5364f050494/stargazers
Run Code Online (Sandbox Code Playgroud)
这似乎不能直接从要点上获得。
您可以检查要点是否已加星标,但像richardcornish/file-git-notes这样的加星标要点在其描述中不包含星号。
请参阅https://api.github.com/gists/4676556
这将使您放弃https://gist.github.com/richardcornish/4676556/stars页面以获得“36”(该要点的星星总数)。
该计数器的 xpath 不是一个明显的路径
//div[@id='js-flash-container']/
div[@class='container']/
div[@class='gist js-gist-container gist-with-sidebar with-full-navigation']/
div[@class='gist-sidebar clearfix']/
div[@class='sunken-menu vertical-right repo-nav js-repo-nav js-repository-container-pjax js-octicon-loaders']/
div[@class='sunken-menu-contents']/
ul[@class='sunken-menu-group']/
li[@class='tooltipped tooltipped-w'][3]/
a[@class='sunken-menu-item selected']/
span[@class='counter']
Run Code Online (Sandbox Code Playgroud)