更新README;隐藏B站筛选条件
This commit is contained in:
		
							
								
								
									
										165
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								README.md
									
									
									
									
									
								
							@@ -2,30 +2,47 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
> 本仓库中代码仅供学习研究使用,不得用于违法用途,学习使用完毕后请于24小时内删除。
 | 
					> 本仓库中代码仅供学习研究使用,不得用于违法用途,学习使用完毕后请于24小时内删除。
 | 
				
			||||||
>
 | 
					>
 | 
				
			||||||
> 数据来自微博、B站热搜榜单,本项目不对数据真实性做验证,使用数据时请遵守相关平台的相关限制要求。
 | 
					> 数据来自微博、B站(详见下方「数据来源」),本项目不对数据真实性做验证,使用数据时请遵守相关平台的相关限制要求。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 简介
 | 
					## 简介
 | 
				
			||||||
 | 
					
 | 
				
			||||||
您可以将本项目代码部署在服务器上(在本地运行也可),程序会每隔一分钟拉取一次热搜数据,并保存为 `json` 格式文件。
 | 
					您可以将本项目代码部署在服务器上(在本地运行也可),程序会每隔一分钟拉取一次热搜数据,并保存为 `json` 格式文件。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 数据预览
 | 
					## 数据预览
 | 
				
			||||||
 | 
					
 | 
				
			||||||
在部署并启动项目后,您可以在浏览器中打开 `html/index.html` 文件实时预览当前热搜。
 | 
					在部署并启动项目后,您可以在浏览器中打开 `html/index.html` 文件实时预览当前热搜。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 数据来源
 | 
					## 数据来源
 | 
				
			||||||
 | 
					
 | 
				
			||||||
微博热搜接口:https://weibo.com/ajax/statuses/hot_band
 | 
					**微博热搜**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> 该接口来自页面:https://weibo.com/hot/search
 | 
					页面:https://weibo.com/hot/search
 | 
				
			||||||
 | 
					
 | 
				
			||||||
B站热搜接口:https://app.bilibili.com/x/v2/search/trending/ranking
 | 
					接口:https://weibo.com/ajax/statuses/hot_band
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> 该接口来自页面:https://www.bilibili.com/blackboard/activity-trending-topic.html
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
B站排行榜接口:https://api.bilibili.com/x/web-interface/ranking/v2?type=all
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
> 该接口来自页面:https://www.bilibili.com/v/popular/rank/all
 | 
					**B站热搜**
 | 
				
			||||||
> (切换到其他榜单再切换回来会调用此接口)
 | 
					
 | 
				
			||||||
 | 
					页面:https://www.bilibili.com/blackboard/activity-trending-topic.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					接口:https://app.bilibili.com/x/v2/search/trending/ranking
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					**B站排行榜**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					页面:https://www.bilibili.com/v/popular/rank/all
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					接口:https://api.bilibili.com/x/web-interface/ranking/v2?type=all
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(切换到其他榜单再切换回来会调用此接口)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 运行环境
 | 
					## 运行环境
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,6 +50,8 @@ B站排行榜接口:https://api.bilibili.com/x/web-interface/ranking/v2?type=a
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
项目使用 node 开发,以下部署流程默认您已安装了 `Git`、`Nodejs`。
 | 
					项目使用 node 开发,以下部署流程默认您已安装了 `Git`、`Nodejs`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 部署
 | 
					## 部署
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1. 克隆仓库(或直接下载压缩包)
 | 
					1. 克隆仓库(或直接下载压缩包)
 | 
				
			||||||
@@ -77,10 +96,16 @@ npm i
 | 
				
			|||||||
# pm2 delete weibo-hotband-bot
 | 
					# pm2 delete weibo-hotband-bot
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 说明
 | 
					## 说明
 | 
				
			||||||
 | 
					
 | 
				
			||||||
项目爬取的数据默认保存在项目目录下的 data 文件夹中,您也可以通过修改 `.env` 文件中的 `DATA_FOLDER` 参数值来自定义数据保存路径。
 | 
					项目爬取的数据默认保存在项目目录下的 data 文件夹中,您也可以通过修改 `.env` 文件中的 `DATA_FOLDER` 参数值来自定义数据保存路径。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### 微博热搜榜
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> 微博热搜在 `weibo_hotband` 子文件夹下
 | 
				
			||||||
 | 
					
 | 
				
			||||||
在程序运行后,该文件夹下会出现 `latest.json` 文件及其余几个文件夹,这些子文件夹中的文件按照以下格式保存:`年/月/日/年月日_时分.json`。
 | 
					在程序运行后,该文件夹下会出现 `latest.json` 文件及其余几个文件夹,这些子文件夹中的文件按照以下格式保存:`年/月/日/年月日_时分.json`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
每次爬取后,`latest.json`中的数据都会被覆盖为最新的热搜数据。
 | 
					每次爬取后,`latest.json`中的数据都会被覆盖为最新的热搜数据。
 | 
				
			||||||
@@ -92,3 +117,127 @@ npm i
 | 
				
			|||||||
`final` 文件夹中的数据是从原始数据中抽离出的有用数据,并重新整理得到的。
 | 
					`final` 文件夹中的数据是从原始数据中抽离出的有用数据,并重新整理得到的。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`regulation` 文件夹中的数据主要用于观测原始值与显示值不同的热搜,这部分热搜猜测可能是经过微博平台调控的。(这部分数据没有太大意义,可以忽略)
 | 
					`regulation` 文件夹中的数据主要用于观测原始值与显示值不同的热搜,这部分热搜猜测可能是经过微博平台调控的。(这部分数据没有太大意义,可以忽略)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### B站热搜榜
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> 微博热搜在 `bilibili_hotband` 子文件夹下
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					在程序运行后,该文件夹下会出现 `latest.json` 文件及其余几个文件夹,这些子文件夹中的文件按照以下格式保存:`年/月/日/年月日_时分.json`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					每次爬取后,`latest.json`中的数据都会被覆盖为最新的热搜数据。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`origin` 文件夹中的数据是通过Api接口获取到的原始数据,此处仅仅去除了 `trackid`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`final` 文件夹中的数据是从原始数据中抽离出的有用数据,并重新整理得到的。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### B站排行榜
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> 微博热搜在 `bilibili_rank` 子文件夹下
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					在程序运行后,该文件夹下会出现 `latest.json` 文件及其余几个文件夹,这些子文件夹中的文件按照以下格式保存:`年/月/日/年月日_时分.json`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					每次爬取后,`latest.json`中的数据都会被覆盖为最新的热搜数据。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`origin` 文件夹中的数据是通过Api接口获取到的原始数据,没有经过任何处理。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 目录结构
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### 项目目录结构
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					hotband                                      // 本项目
 | 
				
			||||||
 | 
					├─ data                                      // 爬取的数据(启动项目后自动创建)
 | 
				
			||||||
 | 
					├─ html                                      // html 页面
 | 
				
			||||||
 | 
					│  ├─ assets                                 
 | 
				
			||||||
 | 
					│  │  ├─ css                                 // CSS 样式
 | 
				
			||||||
 | 
					│  │  │  └─                                  
 | 
				
			||||||
 | 
					│  │  ├─ image                               // 前端图片资源
 | 
				
			||||||
 | 
					│  │  │  ├─ ...                              
 | 
				
			||||||
 | 
					│  │  └─ js                                  
 | 
				
			||||||
 | 
					│  │     └─ isMobile.js                      
 | 
				
			||||||
 | 
					│  ├─ bilibili_hotband.html                  
 | 
				
			||||||
 | 
					│  ├─ bilibili_rank.html                     
 | 
				
			||||||
 | 
					│  └─ weibo_hotband.html                     
 | 
				
			||||||
 | 
					├─ src                                       // 数据爬取核心代码
 | 
				
			||||||
 | 
					│  ├─ utils                                  // 工具类代码
 | 
				
			||||||
 | 
					│  │  ├─ fileUtils.js                        
 | 
				
			||||||
 | 
					│  │  └─ requestUtils.js                     
 | 
				
			||||||
 | 
					│  ├─ execute_command.js                     // 执行命令行脚本(暂时没用到)
 | 
				
			||||||
 | 
					│  ├─ get_bilibili_hotband.js                // 获取 B站热搜榜 代码
 | 
				
			||||||
 | 
					│  ├─ get_bilibili_rank.js                   // 爬取 B站排行榜 代码
 | 
				
			||||||
 | 
					│  └─ get_weibo_hotband.js                   // 爬取 微博热搜榜 代码
 | 
				
			||||||
 | 
					├─ .env.example                              // 项目配置文件模板
 | 
				
			||||||
 | 
					├─ .env                                      // 项目配置文件(需要自行创建)
 | 
				
			||||||
 | 
					├─ index.html                                // html 页面打开文件
 | 
				
			||||||
 | 
					├─ index.js                                  // node 项目启动入口文件
 | 
				
			||||||
 | 
					├─ nodemon.json                              
 | 
				
			||||||
 | 
					├─ package-lock.json                         
 | 
				
			||||||
 | 
					├─ package.json                              
 | 
				
			||||||
 | 
					├─ pm2 restart.bat                           
 | 
				
			||||||
 | 
					├─ pm2 restart.sh                            
 | 
				
			||||||
 | 
					├─ pm2 start.bat                             
 | 
				
			||||||
 | 
					├─ pm2 start.sh                              
 | 
				
			||||||
 | 
					├─ pm2 stop.bat                              
 | 
				
			||||||
 | 
					├─ pm2 stop.sh                               
 | 
				
			||||||
 | 
					└─ README.md                                 // 项目自述文件
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### data 目录结构
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data 文件夹下的目录结构如下
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					data                                      
 | 
				
			||||||
 | 
					├─ bilibili-hotband                       
 | 
				
			||||||
 | 
					│  ├─ final / origin                      
 | 
				
			||||||
 | 
					│  │  └─ xxxx                             // 年
 | 
				
			||||||
 | 
					│  │     └─ xx                            // 月
 | 
				
			||||||
 | 
					│  │        └─ xx                         // 日
 | 
				
			||||||
 | 
					│  │           ├─ xxxxxxxx_xxxx.min.json  // 年月日_时分秒.min.json
 | 
				
			||||||
 | 
					│  └─ latest.json                         // 最新的json文件
 | 
				
			||||||
 | 
					├─ bilibili-rank                          
 | 
				
			||||||
 | 
					│  ├─ origin                              
 | 
				
			||||||
 | 
					│  │  └─ xxxx                             // 年
 | 
				
			||||||
 | 
					│  │     └─ xx                            // 月
 | 
				
			||||||
 | 
					│  │        └─ xx                         // 日
 | 
				
			||||||
 | 
					│  │           ├─ xxxxxxxx_xxxx.min.json  // 年月日_时分秒.min.json
 | 
				
			||||||
 | 
					│  └─ latest.json                         // 最新的json文件
 | 
				
			||||||
 | 
					└─ weibo-hotband                          
 | 
				
			||||||
 | 
					   ├─ origin / final / simplify           
 | 
				
			||||||
 | 
					   │  └─ xxxx                             // 年
 | 
				
			||||||
 | 
					   │     └─ xx                            // 月
 | 
				
			||||||
 | 
					   │        └─ xx                         // 日
 | 
				
			||||||
 | 
					   │           ├─ xxxxxxxx_xxxx.min.json  // 年月日_时分秒.min.json
 | 
				
			||||||
 | 
					   ├─ regulation                          
 | 
				
			||||||
 | 
					   │  └─ xxxx                             // 年
 | 
				
			||||||
 | 
					   │     └─ xx                            // 月
 | 
				
			||||||
 | 
					   │        └─ xx                         // 日
 | 
				
			||||||
 | 
					   │           ├─ xxxxxxxx_xxxx.json      // 年月日_时分秒.json
 | 
				
			||||||
 | 
					   └─ latest.json                         // 最新的json文件
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### 题外话:怎么生成目录结构?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> 有很多小伙伴在问像上方的目录结构是如何生成的,这里跟大家说下:
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					> 1. Windows 下可以通过 `tree` 命令来生成,例如:
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					>    ```bash
 | 
				
			||||||
 | 
					>    tree /f > xxx.txt
 | 
				
			||||||
 | 
					>    ```
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					> 2. 使用 VS Code 插件
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					>    我使用的是 [tree-generator](https://marketplace.visualstudio.com/items?itemName=xboxyan.tree-generator) 这个插件,安装之后直接在文件夹上右键即可生成
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					> 3. 另外还有一些其他方法也可以生成,大家可以自己探索。
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,10 +31,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
    <div style="text-align: center;">
 | 
					    <div style="text-align: center;">
 | 
				
			||||||
        <h1 id="title">B站排行榜(调整中)</h1>
 | 
					        <h1 id="title">B站排行榜</h1>
 | 
				
			||||||
        <p id="dynamic-note"></p>
 | 
					        <p id="dynamic-note"></p>
 | 
				
			||||||
        <hr>
 | 
					        <hr>
 | 
				
			||||||
        <div>
 | 
					        <div style="display: none;">
 | 
				
			||||||
            显示字段:
 | 
					            显示字段:
 | 
				
			||||||
            <label for="show_emoticon">
 | 
					            <label for="show_emoticon">
 | 
				
			||||||
                <input type="checkbox" class="filter_checkbox" name="show_emoticon" id="show_emoticon"
 | 
					                <input type="checkbox" class="filter_checkbox" name="show_emoticon" id="show_emoticon"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user