TopList

今日热榜,一个获取各大热门网站热门头条的聚合网站,使用Go语言编写,多协程异步快速抓取信息,预览:https://www.printf520.com/hot.html

Github stars Tracking Chart

今日热榜

Build Status
License

今日热榜是一个获取各大热门网站热门头条的聚合网站,使用Go语言编写,多协程异步快速抓取信息,预览:https://www.printf520.com/hot.html
DeepinScrot-4337.png

安装教程

  1. 编译

    cd {root_path} # 项目根目录
    go build -o ./App/GetHot App/GetHot.go
    go build -o ./App/Server App/Server.go 
    
  2. 创建数据库,如 news,执行database.sql创建表,更改配置文件Config/mysql.toml

  3. 编辑文件 Html/js/blog/globalConfig.js

    const ServerIp = 'http://{your_domain}:9090' // 替换成服务器域名
    
  4. 部署定时任务/App/GetHot.go爬虫程序,且以守护进程的方式执行Server.go

    crontab -e # 添加一行 0 */1 * * * {root_path}/App/GetHot
    nohup {root_path}/App/Server &
    
  5. 测试

    • 打开http://{yourdomain}:9090/ 即可访问今日热榜

目录说明

TopList/
├── App
│   ├── GetHot.go   爬虫程序需要Cron定时任务执行
│   └── Server.go   Server程序需要守护进程的方式执行
├── Common
│   ├── Db.go       DB组件
│   └── Message.go  
├── Config
│   ├── MySql.go    mysql配置读取组件
│   └── mysql.toml  mysql配置文件需要手动配置
├── Cron
│   ├── GetHot.sh   爬虫Cron程序可以是每小时执行一次
│   └── README.md
├── database.sql    数据库建表文件
├── Html
│   ├── css
│   ├── hot.html    前端热榜展示网页
│   └── js
│  
└── README.md

API说明

获取所有类型

  • Method: GET
  • URL: https://www.printf520.com:8080/GetType
  • Param:无
  • Body:
{
    "Code":0,
    "Message":"获取数据成功",
    "Data":[
        {"id":"1","sort":"63908","title":"知乎"},
        {"id":"2","sort":"21912","title":"虎扑"},
        {"id":"6","sort":"11707","title":"天涯"},
        {"id":"7","sort":"12546","title":"知乎日报"},
       ]}

获取具体类型热榜数据

  • Method: GET
  • URL: https://www.printf520.com:8080/GetTypeInfo?id=2
  • Param:id
  • Body:
{
    "Code":0,
    "Message":"获取成功",
    "Data":[
        {
            "title":"
45个经典面试回答提示,分享给即将工作的大家。 zt
",
            "url":"https://bbs.hupu.com//28814429.html"
        },
        {
            "title":"
[名场面]回家的诱惑:洪世贤酒店幽会,抵不住诱惑犯了错! zt
",
            "url":"https://bbs.hupu.com//28818367.html"
        },
        {
            "title":"
张艺兴回应假唱风波。ZT
",
            "url":"https://bbs.hupu.com//28815609.html"
        }
    ]
}

使用说明

  1. fork 项目

参与贡献

  1. Fork 本项目
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

Main metrics

Overview
Name With Ownertophubs/TopList
Primary LanguageGo
Program languageGo (Language Count: 2)
Platform
License:Apache License 2.0
所有者活动
Created At2019-07-15 06:26:39
Pushed At2023-02-23 02:24:26
Last Commit At2022-01-22 09:25:19
Release Count0
用户参与
Stargazers Count4.7k
Watchers Count106
Fork Count0.9k
Commits Count66
Has Issues Enabled
Issues Count76
Issue Open Count42
Pull Requests Count8
Pull Requests Open Count3
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private