当前位置: 首页 > news >正文

网站视频做栏目一般一期多钱北控水务建设发展有限公司网站

网站视频做栏目一般一期多钱,北控水务建设发展有限公司网站,软件设计师中级,想要个免费网站看到有人使用Github 提供的API做了GitHub rank的网站#xff0c;由于以前没有使用过Github的API#xff0c;所以打算自己动手尝试一下。在线效果 1. Token 生成 使用API前需要先申请开发者Token#xff0c;在Settings -- Developer settings -- Personal access t…看到有人使用Github 提供的API做了GitHub rank的网站由于以前没有使用过Github的API所以打算自己动手尝试一下。在线效果 1. Token 生成 使用API前需要先申请开发者Token在Settings -- Developer settings -- Personal access tokens里自行生成。生成好的token要记好不然后面就看不见了只能重新生成。 2. API对接 安装octokit npm install octokit使用 import { Octokit } from octokit;const octokit new Octokit({ auth: YOUR-TOKEN });查询排名前100的数据列表 查询followers大于1000的用户取前100条数据 const getUsers async () {const q followers:1000 location:China;const result await octokit.request(GET /search/users, {q,per_page: 100, // 每页最多100条数据});return result.data.items; };数据结构如下: [{login: octocat,id: 1,node_id: MDQ6VXNlcjE,avatar_url: https://github.com/images/error/octocat_happy.gif,gravatar_id: ,url: https://api.github.com/users/octocat,html_url: https://github.com/octocat,followers_url: https://api.github.com/users/octocat/followers,following_url: https://api.github.com/users/octocat/following{/other_user},gists_url: https://api.github.com/users/octocat/gists{/gist_id},starred_url: https://api.github.com/users/octocat/starred{/owner}{/repo},subscriptions_url: https://api.github.com/users/octocat/subscriptions,organizations_url: https://api.github.com/users/octocat/orgs,repos_url: https://api.github.com/users/octocat/repos,events_url: https://api.github.com/users/octocat/events{/privacy},received_events_url: https://api.github.com/users/octocat/received_events,type: User,site_admin: false} ]更新信息查看官网文档 根据login获取用户信息 上面是批量获取的用户信息缺少我们想要的数据通过用户的login获取详细信息比如:name、blog、location、company、followers等数据更多字段查看官网文档; const getUsersInfo async (items []) {const userInfoMap {}for (let user of items) {if (!userInfoMap[user.login]) {const result await octokit.request(GET /users/${user.login});const userInfo result.data;if (userInfo) {userInfoMap[user.id] {html_url: userInfo.html_url,login: userInfo.login,name: userInfo.name,blog: userInfo.blog,location: userInfo.location,company: userInfo.company,followers: userInfo.followers,following: userInfo.following,public_repos: userInfo.public_repos,twitter_username: userInfo.twitter_username,created_at: userInfo.created_at,};}}}return userInfoMap; };数据更新 上面的代码基本就能实现从github获取排名数据了如果每次都通过接口获取那耗时会相当的长所以可以将数据缓存起来每天更新一次数据即可。 通过服务器的crontabs定时功能每天凌晨拉取一次我将上面的代码放到了github-rank.mjs里将获取到的数据存在json文件里下面时添加到crontabs的配置。 0 0 * * * node /app/cron/github-rank.mjs /var/log/cron.log前端使用nextjs在服务器渲染时读取json文件的数据即可。 如果使用的docker需要注意alpine版本crontab的目录是var/spool/cron/crontabs不是/etc/cron.d。
http://www.pierceye.com/news/57337/

相关文章:

  • 宁波市建设厅网站首页福州建设厅网站
  • 网站设计教学wordpress手机浏览
  • 工厂 电商网站建设wordpress博客申请
  • 怎么自己创建一个免费网站空间网站认证
  • 回收网站怎么做百度电脑版登录网站
  • 左侧固定导航栏的网站个人网站免费搭建
  • 网站的建立目的网站前台建设
  • 做网站私活多少钱网站内容怎么写
  • 网站长尾关键词优化完成网站集约化建设
  • 网站策划书模板做网站编辑大专可以吗
  • 网站建设策划框架亚马逊雨林生物
  • html制作网站学校html网站模板代码
  • 公司网站模板中英文如何用wordpress做一个企业网站
  • 东莞市网站建设怎么样设计网页多少钱
  • 徐州数据网站建设介绍萝岗定制型网站建设
  • 做网站前端程序员信阳做网站公司汉狮价格
  • 网站页脚代码中国住房与城乡建设部官方网站
  • App网站建设 高品质网站建设甘肃省城乡建设局网站首页
  • 百度云虚拟主机如何建设网站百度服务中心人工24小时电话
  • 如何在百度上建立网站上海黑马程序员培训机构地址
  • 工程建设服务平台seo搜索引擎优化排名哪家更专业
  • 陕西省住建厅网站官网手机百度登录入口
  • 深圳市招聘信息网站外链提高网站权重
  • 做网站有什么语言好网络科技有限公司简介
  • 怎么在京东做网站网站运营费用
  • asp.net 获取网站的绝对路径公司官网建设多少钱
  • 中国建设银行人事网站公司简介模板图片
  • 网站建设结课总结明光市建设局网站
  • 永久免费网站搭建万网网站空间购买
  • 江门建设网站wordpress 安装 插件