2021-12-20 18:48:35 +08:00
|
|
|
|
// Package crawler ...
|
|
|
|
|
//
|
|
|
|
|
// Description : crawler ...
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 2021-12-20 4:50 PM
|
|
|
|
|
package crawler
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/gocolly/colly"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// IRequestHandler 请求结果的处理
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 4:50 PM 2021/12/20
|
|
|
|
|
type IRequestHandler interface {
|
|
|
|
|
// OnRequest 在发起请求前被调用
|
|
|
|
|
OnRequest() colly.RequestCallback
|
|
|
|
|
// OnError 请求过程中如果发生错误被调用
|
2021-12-20 19:03:04 +08:00
|
|
|
|
OnError() colly.ErrorCallback
|
2021-12-20 18:48:35 +08:00
|
|
|
|
// OnResponse 收到回复后被调用
|
2021-12-20 19:03:04 +08:00
|
|
|
|
OnResponse() colly.ResponseCallback
|
2021-12-20 18:48:35 +08:00
|
|
|
|
// OnHTML 在OnResponse之后被调用,如果收到的内容是HTML
|
|
|
|
|
OnHTML() (string, colly.HTMLCallback)
|
|
|
|
|
// OnScraped 在OnHTML之后被调用
|
2021-12-20 19:03:04 +08:00
|
|
|
|
OnScraped() colly.ScrapedCallback
|
2021-12-20 18:48:35 +08:00
|
|
|
|
}
|