visitor_test.go 648 B

12345678910111213141516171819202122232425262728
  1. package qianlima
  2. import (
  3. "fmt"
  4. "git.aionnect.com/hello-go/spider/common"
  5. "git.aionnect.com/hello-go/spider/spiders"
  6. "git.aionnect.com/hello-go/spider/spiders/qianlima/items"
  7. "net/http"
  8. "testing"
  9. )
  10. func TestVisitorSpider(t *testing.T) {
  11. // 从起始页开始执行爬虫
  12. params := &items.PagingParams{PagingNo: 1, DaysLimit: 7}
  13. startingUrl := fmt.Sprintf(TargetUrl, params.PagingNo)
  14. target := &common.Target{
  15. Key: VisitorPaging,
  16. Method: http.MethodPost,
  17. URL: startingUrl,
  18. Referer: RefererUrl,
  19. Item: params,
  20. }
  21. spiders.Run(target,
  22. NewVisitorPagingSpider(),
  23. NewVisitorDetailSpider(),
  24. )
  25. fmt.Println("Done!")
  26. }