如何使用GitHub API在GitHub中获取存储库的依存关系信息?
当我使用GitHub API v4获取一些信息时,我可以使用 repository.dependencyGraphManifests
轻松获得依赖关系.但是我找不到任何使用GitHub API v4来获取依赖项信息的方法,尽管我可以在 Insights-> Dependency Graph-> Dependents
中看到它.我想知道是否有任何可能的方法可以在GitHub存储库中获取受抚养人信息?无论是GitHub API还是其他东西.
When I was using GitHub API v4 to get some information, I can easily get dependencies by using repository.dependencyGraphManifests
. But I can't find any way to use GitHub API v4 to get the dependents information, though I can see it in the Insights->Dependency Graph->Dependents
.
I want to know if there is any possible way to get the dependents information in a GitHub repository? Whether GitHub API or something else.
我认为您无法使用Github API(Rest或Graphql)获得依赖项项目,一种方法可能是使用如下所示的抓取方式 python 脚本:
I don't think you can get the dependents project using Github API (Rest or Graphql), one way could be to use scraping like the following python script :
import requests
from bs4 import BeautifulSoup
repo = "expressjs/express"
page_num = 3
url = 'https://github.com/{}/network/dependents'.format(repo)
for i in range(page_num):
print("GET " + url)
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
data = [
"{}/{}".format(
t.find('a', {"data-repository-hovercards-enabled":""}).text,
t.find('a', {"data-hovercard-type":"repository"}).text
)
for t in soup.findAll("div", {"class": "Box-row"})
]
print(data)
print(len(data))
paginationContainer = soup.find("div", {"class":"paginate-container"}).find('a')
if paginationContainer:
url = paginationContainer["href"]
else:
break