标签:xtend nbsp user day python amp 日期 存在 实现
GitHub 给了开发者相当丰富的 API 接口 https://developer.github.com/v3/,包括认证,搜索,活动等接口,但就是没有提供获取 Trending 的接口。因此,需要自己来实现这个api
Github地址: https://github.com/ngauerh/GithubTrendingApi (求个star),一下请求方式均为get请求。
请求地址: http://132.232.132.144:8009/api
请求结果:
{ "success": true, "count": 25, "msg": [ { # 仓库名称 "repo": "Librefox", # 项目语言 "language": "JavaScript", # 项目拥有着 "user": "intika", # 项目简介 "about": "Librefox: Firefox with privacy enhancements", # 项目地址 "link": "https://github.com/intika/Librefox", # 项目star数 "stars": "495", # 项目fork数 "forks": "14", # 新增star数 "new_stars": "117 stars today", # 项目维护者头像地址 "avatars": [ "https://avatars2.githubusercontent.com/u/6892180?s=40&v=4", "https://avatars0.githubusercontent.com/u/152493?s=40&v=4", "https://avatars3.githubusercontent.com/u/2353785?s=40&v=4", "https://avatars3.githubusercontent.com/u/38463143?s=40&v=4" ] }, ...
请求地址 http://132.232.132.144:8009/api/developers
{ success: true, count: 25, msg: [ { # 开发者用户名 username: "thunlp (THUNLP)", # 开发者头像 avatar: "https://avatars1.githubusercontent.com/u/18389035?s=96&v=4", # 开发者主页 userlink: "https://github.com/thunlp", # 开发者热门项目 repo: "NRLPapers", # 热门项目简介 repo_about: "Must-read papers on network representation learning (NRL) / network embedding (NE)" },
请求路径
http://132.232.132.144:8009/api?lang=python&since=daily
http://132.232.132.144:8009/api/developers?lang=python&since=daily
请求参数:
lang 语言, 参数来自config.py中的 GithubLanguages
since 日期,参数有 daily,weekly, monthly
daily 每天 weekly 每周 monthly 每月
请求地址: http://132.232.132.144:8009/api/languages
返回结果:
{ "success": true, "count": 490, "msg": [ "Zimpl", "Zephir", "YASnippet", "YARA", "YANG", "YAML", "Yacc", "Xtend", "XSLT", "XS", ...
当请求的lang或since不存在时,请求出错。错误结果为:
{ "success": false, "count": 0, "msg": "请求错误" }
1. git clone https://github.com/ngauerh/GithubTrendingApi.git
2. pip install -r requirements.txt
3 . 修改config.py 文件
GithubLanguages:要抓取的语言(在http://132.232.132.144:8009/api/languages里进行选择)
SinceDate: 不能更改
DB: 数据库配置
SERVER_PORT: 要运行的api服务的端口号
CRAWL_INTERVAL: 抓取间隔时间(实际间隔时间会曾经一个多小时)
4. 运行models.py 生成数据表(数据库格式需要为utf8mb4,如果格式为utf8则数据存入时会出错)
5. 运行run.py
标签:xtend nbsp user day python amp 日期 存在 实现
原文地址:https://www.cnblogs.com/niuu/p/10185304.html