Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project#123]简单改成一个可以在windows系统下可以跑起来的项目~ #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions App/GetHot.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func SaveDataToJson(data interface{}) string {
// V2EX
func (spider Spider) GetV2EX() []map[string]interface{} {
url := "https://www.v2ex.com/?tab=hot"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func (spider Spider) GetV2EX() []map[string]interface{} {

func (spider Spider) GetITHome() []map[string]interface{} {
url := "https://www.ithome.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func (spider Spider) GetITHome() []map[string]interface{} {

// 知乎
func (spider Spider) GetZhiHu() []map[string]interface{} {
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func (spider Spider) GetZhiHu() []map[string]interface{} {
// 微博
func (spider Spider) GetWeiBo() []map[string]interface{} {
url := "https://s.weibo.com/top/summary"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -222,7 +222,7 @@ func (spider Spider) GetTieBa() []map[string]interface{} {
// 豆瓣
func (spider Spider) GetDouBan() []map[string]interface{} {
url := "https://www.douban.com/group/explore"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -264,7 +264,7 @@ func (spider Spider) GetDouBan() []map[string]interface{} {
// 天涯
func (spider Spider) GetTianYa() []map[string]interface{} {
url := "http://bbs.tianya.cn/list.jsp?item=funinfo&grade=3&order=1"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -307,7 +307,7 @@ func (spider Spider) GetTianYa() []map[string]interface{} {
// 虎扑
func (spider Spider) GetHuPu() []map[string]interface{} {
url := "https://bbs.hupu.com/all-gambia"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -350,7 +350,7 @@ func (spider Spider) GetHuPu() []map[string]interface{} {
// Github
func (spider Spider) GetGitHub() []map[string]interface{} {
url := "https://github.com/trending"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -393,7 +393,7 @@ func (spider Spider) GetGitHub() []map[string]interface{} {

func (spider Spider) GetBaiDu() []map[string]interface{} {
url := "http://top.baidu.com/buzz?b=341&c=513&fr=topbuzz_b1"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -434,7 +434,7 @@ func (spider Spider) GetBaiDu() []map[string]interface{} {

func (spider Spider) Get36Kr() []map[string]interface{} {
url := "https://36kr.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -485,7 +485,7 @@ func (spider Spider) Get36Kr() []map[string]interface{} {

func (spider Spider) GetQDaily() []map[string]interface{} {
url := "https://www.qdaily.com/tags/29.html"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -529,7 +529,7 @@ func (spider Spider) GetQDaily() []map[string]interface{} {

func (spider Spider) GetGuoKr() []map[string]interface{} {
url := "https://www.guokr.com/scientific/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -573,7 +573,7 @@ func (spider Spider) GetGuoKr() []map[string]interface{} {

func (spider Spider) GetHuXiu() []map[string]interface{} {
url := "https://www.huxiu.com/article"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -627,7 +627,7 @@ func (spider Spider) GetHuXiu() []map[string]interface{} {

func (spider Spider) GetDBMovie() []map[string]interface{} {
url := "https://movie.douban.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -667,7 +667,7 @@ func (spider Spider) GetDBMovie() []map[string]interface{} {

func (spider Spider) GetZHDaily() []map[string]interface{} {
url := "http://daily.zhihu.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -709,7 +709,7 @@ func (spider Spider) GetZHDaily() []map[string]interface{} {

func (spider Spider) GetSegmentfault() []map[string]interface{} {
url := "https://segmentfault.com/hottest"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -751,7 +751,7 @@ func (spider Spider) GetSegmentfault() []map[string]interface{} {

func (spider Spider) GetHacPai() []map[string]interface{} {
url := "https://hacpai.com/domain/play"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -793,7 +793,7 @@ func (spider Spider) GetHacPai() []map[string]interface{} {

func (spider Spider) GetWYNews() []map[string]interface{} {
url := "http://news.163.com/special/0001386F/rank_whole.html"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -837,7 +837,7 @@ func (spider Spider) GetWYNews() []map[string]interface{} {

func (spider Spider) GetWaterAndWood() []map[string]interface{} {
url := "https://www.newsmth.net/nForum/mainpage?ajax"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -899,7 +899,7 @@ func (spider Spider) GetWaterAndWood() []map[string]interface{} {

func (spider Spider) GetNGA() []map[string]interface{} {
url := "http://nga.cn/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -943,7 +943,7 @@ func (spider Spider) GetNGA() []map[string]interface{} {

func (spider Spider) GetCSDN() []map[string]interface{} {
url := "https://www.csdn.net/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -988,7 +988,7 @@ func (spider Spider) GetCSDN() []map[string]interface{} {
// https://weixin.sogou.com/?pid=sogou-wsse-721e049e9903c3a7&kw=
func (spider Spider) GetWeiXin() []map[string]interface{} {
url := "https://weixin.sogou.com/?pid=sogou-wsse-721e049e9903c3a7&kw="
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ func (spider Spider) GetWeiXin() []map[string]interface{} {

func (spider Spider) GetKD() []map[string]interface{} {
url := "http://www.kdnet.net/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -1080,7 +1080,7 @@ func (spider Spider) GetKD() []map[string]interface{} {

func (spider Spider) GetMop() []map[string]interface{} {
url := "http://www.mop.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -1138,7 +1138,7 @@ func (spider Spider) GetMop() []map[string]interface{} {

func (spider Spider) GetChiphell() []map[string]interface{} {
url := "https://www.chiphell.com/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ func (spider Spider) GetChiphell() []map[string]interface{} {

func (spider Spider) GetJianDan() []map[string]interface{} {
url := "http://jandan.net/"
timeout := time.Duration(5 * time.Second) //超时时间5s
timeout := time.Duration(50 * time.Second) //超时时间5s
client := &http.Client{
Timeout: timeout,
}
Expand Down
22 changes: 13 additions & 9 deletions App/Server.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package main

import (
"../Common"
"../Config"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"path/filepath"
// "os/signal"
"regexp"
"syscall"
// "syscall"
"text/template"

"../Common"
"../Config"
)

func GetTypeInfo(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -47,7 +47,7 @@ kill -SIGUSR1 PID 可平滑重新读取mysql配置
*/
func SyncMysqlCfg() {
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGUSR1)
// signal.Notify(s, syscall.SIGUSR1)
go func() {
for {
<-s
Expand All @@ -63,13 +63,17 @@ func main() {
http.HandleFunc("/GetType", GetType) // 设置访问的路由
http.HandleFunc("/GetConfig", GetConfig) // 设置访问的路由

dir, _ := filepath.Abs(`.`)

// 静态资源
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("../Html/css/"))))
http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("../Html/js/"))))
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir(dir+"/Html/css/"))))
http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir(dir+"/Html/js/"))))

// 首页
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("../Html/hot.html")
dir, _ := filepath.Abs(`.`)
t, err := template.ParseFiles(dir + "/Html/hot.html")
println(dir)
if err != nil {
log.Println("err")
}
Expand Down
2 changes: 1 addition & 1 deletion Config/MySql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func GetMySqlFilePath() string {
log.Fatal("获取目录失败")
}
if strings.HasSuffix(currentPath, "App") {
return strings.ReplaceAll(currentPath, "App", "Config") + "/mysql.toml"
return strings.Replace(currentPath, "App", "Config", 0) + "/mysql.toml"
}
return currentPath + "/Config/mysql.toml"
}
Expand Down
2 changes: 1 addition & 1 deletion Config/mysql.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Source = "user:password@tcp(ip:port)/database?charset=utf8mb4"
Source = "root:root@tcp(10.199.147.51:3309)/lgy_top_list?charset=utf8mb4"
Driver = "mysql"
6 changes: 6 additions & 0 deletions proxy_get_dependencies.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080
go get -d -v ./...
echo ...
pause