juejin-article-trends

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

掘金热门文章排行榜

Juejin Popular Article Rankings

功能概述

Function Overview

此技能用于获取掘金(juejin.cn)网站的技术文章排行榜数据,包括:
  • 文章分类列表(前端、后端、AI、移动开发等)
  • 各分类的热门文章排行榜
  • 文章详细信息(标题、作者、阅读量、点赞数等)
This skill is used to obtain technical article ranking data from the Juejin (juejin.cn) website, including:
  • Article category list (Front-end, Back-end, AI, Mobile Development, etc.)
  • Popular article rankings for each category
  • Detailed article information (title, author, view count, like count, etc.)

工作流程

Workflow

1. 获取分类列表

1. Get Category List

当用户需要了解掘金文章分类时:
bash
node scripts/juejin.js categories
返回示例:
json
[
  { "id": "6809637769959178254", "name": "前端" },
  { "id": "6809637769959178255", "name": "后端" },
  { "id": "6809637769959178256", "name": "Android" },
  { "id": "6809637769959178257", "name": "iOS" },
  { "id": "6809637769959178258", "name": "人工智能" },
  { "id": "6809637769959178260", "name": "开发工具" },
  { "id": "6809637769959178261", "name": "代码人生" },
  { "id": "6809637769959178262", "name": "阅读" }
]
When you need to know Juejin article categories:
bash
node scripts/juejin.js categories
Return Example:
json
[
  { "id": "6809637769959178254", "name": "前端" },
  { "id": "6809637769959178255", "name": "后端" },
  { "id": "6809637769959178256", "name": "Android" },
  { "id": "6809637769959178257", "name": "iOS" },
  { "id": "6809637769959178258", "name": "人工智能" },
  { "id": "6809637769959178260", "name": "开发工具" },
  { "id": "6809637769959178261", "name": "代码人生" },
  { "id": "6809637769959178262", "name": "阅读" }
]

2. 获取热门文章

2. Get Popular Articles

当用户需要获取特定分类的热门文章时:
bash
node scripts/juejin.js articles <category_id> [type] [limit]
参数:
  • category_id
    : 分类ID(从分类列表获取)
  • type
    : 排序类型,可选
    hot
    (热门) 或
    new
    (最新),默认
    hot
  • limit
    : 返回文章数量,默认20
返回示例:
json
[
  {
    "title": "文章标题",
    "brief": "文章摘要...",
    "author": "作者名",
    "articleId": "123456789",
    "popularity": 100,
    "viewCount": 5000,
    "likeCount": 200,
    "collectCount": 150,
    "commentCount": 50,
    "url": "https://juejin.cn/post/123456789",
    "tags": ["JavaScript", "Vue"]
  }
]
When you need to get popular articles of a specific category:
bash
node scripts/juejin.js articles <category_id> [type] [limit]
Parameters:
  • category_id
    : Category ID (obtained from the category list)
  • type
    : Sorting type, optional
    hot
    (popular) or
    new
    (latest), default is
    hot
  • limit
    : Number of returned articles, default is 20
Return Example:
json
[
  {
    "title": "文章标题",
    "brief": "文章摘要...",
    "author": "作者名",
    "articleId": "123456789",
    "popularity": 100,
    "viewCount": 5000,
    "likeCount": 200,
    "collectCount": 150,
    "commentCount": 50,
    "url": "https://juejin.cn/post/123456789",
    "tags": ["JavaScript", "Vue"]
  }
]

使用示例

Usage Examples

查看所有分类

View All Categories

bash
node scripts/juejin.js categories
bash
node scripts/juejin.js categories

获取前端热门文章(前10篇)

Get Top 10 Front-end Popular Articles

bash
node scripts/juejin.js articles 6809637769959178254 hot 10
bash
node scripts/juejin.js articles 6809637769959178254 hot 10

获取后端最新文章

Get Latest Back-end Articles

bash
node scripts/juejin.js articles 6809637769959178255 new 15
bash
node scripts/juejin.js articles 6809637769959178255 new 15

API说明

API Description

此脚本使用掘金公开API:
  • 分类列表:
    https://api.juejin.cn/tag_api/v1/query_category_briefs
  • 文章排行:
    https://api.juejin.cn/content_api/v1/content/article_rank?category_id={id}&type={type}
This script uses Juejin's public APIs:
  • Category List:
    https://api.juejin.cn/tag_api/v1/query_category_briefs
  • Article Ranking:
    https://api.juejin.cn/content_api/v1/content/article_rank?category_id={id}&type={type}

模块导出

Module Export

脚本也支持作为模块导入使用:
javascript
const { getCategories, getArticles } = require('./juejin.js');

// 获取分类
const categories = await getCategories();

// 获取文章
const articles = await getArticles('6809637769959178254', 'hot', 10);
The script also supports being imported as a module:
javascript
const { getCategories, getArticles } = require('./juejin.js');

// Get categories
const categories = await getCategories();

// Get articles
const articles = await getArticles('6809637769959178254', 'hot', 10);