fix
This commit is contained in:
parent
7fd4acd238
commit
f358a74079
@ -24,7 +24,6 @@ import (
|
||||
|
||||
type FreeGOGCrawler struct {
|
||||
logger *zap.Logger
|
||||
session *ccs.Session
|
||||
}
|
||||
|
||||
func NewFreeGOGCrawler(logger *zap.Logger) *FreeGOGCrawler {
|
||||
@ -34,25 +33,22 @@ func NewFreeGOGCrawler(logger *zap.Logger) *FreeGOGCrawler {
|
||||
}
|
||||
|
||||
func (c *FreeGOGCrawler) getWAFSession() (*ccs.Session, error) {
|
||||
if c.session == nil {
|
||||
var session ccs.Session
|
||||
var err error
|
||||
if val, exist := cache.Get("freegog_waf_session"); exist {
|
||||
session := ccs.Session{}
|
||||
err := json.Unmarshal([]byte(val), &session)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.session = &session
|
||||
} else {
|
||||
session, err := ccs.WAFSession(config.Config.CFClearanceScraper.Url, constant.FreeGOGListURL)
|
||||
session, err = ccs.WAFSession(config.Config.CFClearanceScraper.Url, constant.FreeGOGListURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.session = &session
|
||||
jsonBytes, _ := json.Marshal(session)
|
||||
_ = cache.AddWithExpire("freegog_waf_session", jsonBytes, 24*time.Hour)
|
||||
}
|
||||
}
|
||||
return c.session, nil
|
||||
return &session, nil
|
||||
}
|
||||
|
||||
func (c *FreeGOGCrawler) Name() string {
|
||||
|
Loading…
Reference in New Issue
Block a user