Github API
https://api.github.com/repos/{owner}/{repo}
例如:https://api.github.com/repos/toddrob99/redball
Docker hub API和Github API整合后的json格式
{
"popularity": 53566932,
"docker_name": "flyway/flyway",
"url": "https://github.com/flyway/flyway",
"github_name": "flyway",
"github_full_name": "flyway/flyway",
"owner": {
"login": "flyway",
"id": 2109532,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjIxMDk1MzI=",
"avatar_url": "https://avatars.githubusercontent.com/u/2109532?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/flyway",
"html_url": "https://github.com/flyway",
"followers_url": "https://api.github.com/users/flyway/followers",
"following_url": "https://api.github.com/users/flyway/following{/other_user}",
"gists_url": "https://api.github.com/users/flyway/gists{/gist_id}",
"starred_url": "https://api.github.com/users/flyway/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/flyway/subscriptions",
"organizations_url": "https://api.github.com/users/flyway/orgs",
"repos_url": "https://api.github.com/users/flyway/repos",
"events_url": "https://api.github.com/users/flyway/events{/privacy}",
"received_events_url": "https://api.github.com/users/flyway/received_events",
"type": "Organization",
"site_admin": false
},
"star": 7202,
"fork": 1387,
"language": "Java",
"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="
},
"size": 545215,
"topics": [
"aurora",
"continuous-delivery",
"continuous-deployment",
"database",
"database-administration",
"database-deployment",
"database-management",
"database-migrations",
"db2",
"devops",
"flyway",
"java",
"java-library",
"mariadb",
"mysql",
"postgresql",
"redgate",
"sql",
"sqlserver"
]
}
request 请求认证Github
1.第一个坑:一定要headers=headers,单单requests.get(dir, headers, timeout=5)认证不了
2.get请求经常卡顿,用timeout=5,超过五秒就报错,然后接收错误重新循环
3.这里的token用的是Personal access tokens (classic)
token="your_token"
headers = {
"Authorization": f"Bearer {token}",
}
dir_github = f"https://api.github.com/repos/{url}"
fd = requests.get(dir, headers=headers, timeout=5)
data = json.loads(fd.text)
正则表达式匹配网站信息
# 例子
sentence1 = "New Relic Infrastructure Kafka Integration (https://github.com/newrelic/nri-kafka)"
sentence2 = "https://github.com/circleci/rabbitmq-delayed (this image is for internal use)"
sentence3 = "https://github.com/jonas747/yagpdb]/afsd/fas/"
# 匹配结果
result1="https://github.com/newrelic/nri-kafka"
result2="https://github.com/circleci/rabbitmq-delayed"
result3="https://github.com/jonas747/yagpdb"
想要得到这样的结果,问了很久的chatgpt3.5都不行,问了下gpt4.0才得到正确答案
pattern = r"(https://github.com/[\w-]+/[\w-]+)"
正则表达式测试网站