如何获取GitHub项目的社交预览?

4
我可以获取到项目,但是它没有检索到该项目的“社交预览”:

enter image description here

我正在使用的链接是: https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD

它返回以下内容:

{
  "id": 215636067,
  "node_id": "MDEwOlJlcG9zaXRvcnkyMTU2MzYwNjc=",
  "name": "BCMIC-PHD",
  "full_name": "AngelRibeiro10/BCMIC-PHD",
  "private": false,
  "owner": {
    "login": "AngelRibeiro10",
    "id": 13433634,
    "node_id": "MDQ6VXNlcjEzNDMzNjM0",
    "avatar_url": "https://avatars2.githubusercontent.com/u/13433634?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/AngelRibeiro10",
    "html_url": "https://github.com/AngelRibeiro10",
    "followers_url": "https://api.github.com/users/AngelRibeiro10/followers",
    "following_url": "https://api.github.com/users/AngelRibeiro10/following{/other_user}",
    "gists_url": "https://api.github.com/users/AngelRibeiro10/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/AngelRibeiro10/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/AngelRibeiro10/subscriptions",
    "organizations_url": "https://api.github.com/users/AngelRibeiro10/orgs",
    "repos_url": "https://api.github.com/users/AngelRibeiro10/repos",
    "events_url": "https://api.github.com/users/AngelRibeiro10/events{/privacy}",
    "received_events_url": "https://api.github.com/users/AngelRibeiro10/received_events",
    "type": "User",
    "site_admin": false
  },
  "html_url": "https://github.com/AngelRibeiro10/BCMIC-PHD",
  "description": "This is a Brain-Computer Music Interfacing Project",
  "fork": false,
  "url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD",
  "forks_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/forks",
  "keys_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/keys{/key_id}",
  "collaborators_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/collaborators{/collaborator}",
  "teams_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/teams",
  "hooks_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/hooks",
  "issue_events_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/issues/events{/number}",
  "events_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/events",
  "assignees_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/assignees{/user}",
  "branches_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/branches{/branch}",
  "tags_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/tags",
  "blobs_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/git/blobs{/sha}",
  "git_tags_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/git/tags{/sha}",
  "git_refs_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/git/refs{/sha}",
  "trees_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/git/trees{/sha}",
  "statuses_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/statuses/{sha}",
  "languages_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/languages",
  "stargazers_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/stargazers",
  "contributors_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/contributors",
  "subscribers_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/subscribers",
  "subscription_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/subscription",
  "commits_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/commits{/sha}",
  "git_commits_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/git/commits{/sha}",
  "comments_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/comments{/number}",
  "issue_comment_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/issues/comments{/number}",
  "contents_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/contents/{+path}",
  "compare_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/compare/{base}...{head}",
  "merges_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/merges",
  "archive_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/{archive_format}{/ref}",
  "downloads_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/downloads",
  "issues_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/issues{/number}",
  "pulls_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/pulls{/number}",
  "milestones_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/milestones{/number}",
  "notifications_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/notifications{?since,all,participating}",
  "labels_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/labels{/name}",
  "releases_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/releases{/id}",
  "deployments_url": "https://api.github.com/repos/AngelRibeiro10/BCMIC-PHD/deployments",
  "created_at": "2019-10-16T20:14:22Z",
  "updated_at": "2019-11-14T16:52:13Z",
  "pushed_at": "2019-11-14T16:52:11Z",
  "git_url": "git://github.com/AngelRibeiro10/BCMIC-PHD.git",
  "ssh_url": "git@github.com:AngelRibeiro10/BCMIC-PHD.git",
  "clone_url": "https://github.com/AngelRibeiro10/BCMIC-PHD.git",
  "svn_url": "https://github.com/AngelRibeiro10/BCMIC-PHD",
  "homepage": null,
  "size": 69612,
  "stargazers_count": 0,
  "watchers_count": 0,
  "language": null,
  "has_issues": true,
  "has_projects": true,
  "has_downloads": true,
  "has_wiki": true,
  "has_pages": false,
  "forks_count": 0,
  "mirror_url": null,
  "archived": false,
  "disabled": false,
  "open_issues_count": 0,
  "license": {
    "key": "apache-2.0",
    "name": "Apache License 2.0",
    "spdx_id": "Apache-2.0",
    "url": "https://api.github.com/licenses/apache-2.0",
    "node_id": "MDc6TGljZW5zZTI="
  },
  "forks": 0,
  "open_issues": 0,
  "watchers": 0,
  "default_branch": "master",
  "temp_clone_token": null,
  "network_count": 0,
  "subscribers_count": 1
}

我想获取这张“社交预览”的图片......但在项目属性的返回中没有显示。

非常感谢 :)


除了手动的方式,还有其他方法吗? - skaul05
1个回答

5

所以无法通过API检索,但在我的情况下,由于我仅在我的网站上显示了前三个存储库,因此手动获取图像URL并不困难。

我是通过将预览图像上传到GitHub,然后右键单击弹出的图像 ->检查,在开发者工具中可以看到该元素具有“background-image:url()”属性,右键单击该URL,然后在新标签页中打开,就会出现您的图像URL!

就像我说的那样,这是一个手动过程,但如果您只需要做几次,那么这并不是一个大问题。那是我的解决方法。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接