TODO: Insert OpenrecRanking Data

This commit is contained in:
eson 2020-07-06 17:58:24 +08:00
parent ae56d86026
commit db782a3533
5 changed files with 44 additions and 18 deletions

View File

@ -3,14 +3,11 @@ package main
// InitConfig 初始化配置加载 config.yaml(yml)
var InitConfig *Config
// SourceStore 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
var SourceStore *Store
func init() {
InitConfig = &Config{}
InitConfig.Load()
SourceStore = NewStore()
storeOpenrec = NewStore()
}
func main() {

View File

@ -7,6 +7,28 @@ import (
"github.com/474420502/hunter"
)
var openrecRanking *OpenrecRanking
// storeOpenrec 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
var storeOpenrec *Store
func init() {
openrecRanking = &OpenrecRanking{}
openrecRanking.PreCurlUrl = `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
-H 'authority: public.openrec.tv' \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
-H 'origin: https://www.openrec.tv' \
-H 'sec-fetch-site: same-site' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://www.openrec.tv/ranking' \
-H 'accept-language: zh-CN,zh;q=0.9' \
-H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
--compressed`
}
/*
CREATE TABLE `platform_openrec` (
`url` text NOT NULL,

View File

@ -32,20 +32,20 @@ func (or *OpenrecRankingTest) Execute(cxt *hunter.TaskContext) {
}
func TestRanking(t *testing.T) {
curlBash := `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
-H 'authority: public.openrec.tv' \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
-H 'origin: https://www.openrec.tv' \
-H 'sec-fetch-site: same-site' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://www.openrec.tv/ranking' \
-H 'accept-language: zh-CN,zh;q=0.9' \
-H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
--compressed`
// curlBash := `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
// -H 'authority: public.openrec.tv' \
// -H 'accept: application/json, text/javascript, */*; q=0.01' \
// -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
// -H 'origin: https://www.openrec.tv' \
// -H 'sec-fetch-site: same-site' \
// -H 'sec-fetch-mode: cors' \
// -H 'sec-fetch-dest: empty' \
// -H 'referer: https://www.openrec.tv/ranking' \
// -H 'accept-language: zh-CN,zh;q=0.9' \
// -H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
// --compressed`
ht := hunter.NewHunter(&OpenrecRankingTest{hunter.PreCurlUrl(curlBash)})
ht := hunter.NewHunter(openrecRanking)
ht.SetShare("test", t)
ht.Execute()
}

3
readme.md Normal file
View File

@ -0,0 +1,3 @@
# 数据监控系统
1. 初版.

View File

@ -2,6 +2,7 @@ package main
import (
"database/sql"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
@ -32,5 +33,8 @@ func NewStore() *Store {
// Save 储存数据
func (store *Store) Save(isource ISource) {
store.db.Exec("insert into `platform_openrec`(url, target_type, source, ext) values(?,?,?,?)", isource.GetUrl(), isource.GetTargetType(), isource.GetSource(), isource.GetExt())
_, err := store.db.Exec("insert into `platform_openrec`(url, target_type, source, ext) values(?,?,?,?)", isource.GetUrl(), isource.GetTargetType(), isource.GetSource(), isource.GetExt())
if err != nil {
log.Println(err)
}
}