task.go 463 B

1234567891011121314151617181920212223242526
  1. package services
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/beego/beego/v2/task"
  6. )
  7. func Task() {
  8. fmt.Println("start crawler")
  9. //SyncRankingFromShangHai()
  10. SyncRankingFromIne()
  11. refreshData := task.NewTask("refreshData", "0 0,30 16-23 * * *", RefreshData)
  12. task.AddTask("数据爬取", refreshData)
  13. task.StartTask()
  14. fmt.Println("end crawler")
  15. }
  16. func RefreshData(cont context.Context) (err error) {
  17. SyncRankingFromShangHai()
  18. SyncRankingFromIne()
  19. return
  20. }