94 lines
2.0 KiB
Go
94 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"github.com/474420502/hunter"
|
|
)
|
|
|
|
/*
|
|
CREATE TABLE `platform_openrec` (
|
|
`url` text NOT NULL,
|
|
`target_type` varchar(64) NOT NULL,
|
|
`source` longtext DEFAULT NULL,
|
|
`ext` json DEFAULT NULL,
|
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
KEY `update_time_idx` (`update_time`),
|
|
KEY `target_type_idx` (`target_type`)
|
|
);
|
|
*/
|
|
|
|
// PlatformOpenrec 存储源结构
|
|
type PlatformOpenrec struct {
|
|
Url string //
|
|
TargetType string //
|
|
Source sql.NullString //
|
|
Ext interface{} //
|
|
UpdateTime time.Time //
|
|
}
|
|
|
|
// GetUpdateTime Get return UpdateTime time.Time
|
|
func (po *PlatformOpenrec) GetUpdateTime() time.Time {
|
|
return po.UpdateTime
|
|
}
|
|
|
|
// SetUpdateTime Set UpdateTime time.Time
|
|
func (po *PlatformOpenrec) SetUpdateTime(UpdateTime time.Time) {
|
|
po.UpdateTime = UpdateTime
|
|
}
|
|
|
|
// GetExt Get return Ext map[string]interface
|
|
func (po *PlatformOpenrec) GetExt() interface{} {
|
|
return po.Ext
|
|
}
|
|
|
|
// SetExt Set Ext map[string]interface
|
|
func (po *PlatformOpenrec) SetExt(Ext interface{}) {
|
|
po.Ext = Ext
|
|
}
|
|
|
|
// GetSource Get return Source sql.NullString
|
|
func (po *PlatformOpenrec) GetSource() sql.NullString {
|
|
return po.Source
|
|
}
|
|
|
|
// SetSource Set Source sql.NullString
|
|
func (po *PlatformOpenrec) SetSource(Source sql.NullString) {
|
|
po.Source = Source
|
|
}
|
|
|
|
// GetTargetType Get return TargetType string
|
|
func (po *PlatformOpenrec) GetTargetType() string {
|
|
return po.TargetType
|
|
}
|
|
|
|
// SetTargetType Set TargetType string
|
|
func (po *PlatformOpenrec) SetTargetType(TargetType string) {
|
|
po.TargetType = TargetType
|
|
}
|
|
|
|
// GetUrl Get return Url string
|
|
func (po *PlatformOpenrec) GetUrl() string {
|
|
return po.Url
|
|
}
|
|
|
|
// SetUrl Set Url string
|
|
func (po *PlatformOpenrec) SetUrl(Url string) {
|
|
po.Url = Url
|
|
}
|
|
|
|
// OpenrecRanking 获取排名任务
|
|
type OpenrecRanking struct {
|
|
hunter.PreCurlUrl
|
|
}
|
|
|
|
// Execute 执行方法
|
|
func (or *OpenrecRanking) Execute(cxt *hunter.TaskContext) {
|
|
resp, err := cxt.Hunt()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
cxt.SetShare("test", string(resp.Content()))
|
|
}
|