Exemplo n.º 1
0
// 获取任务规则采集语义字段
func (self *Spider) GetOutFeild(resp *context.Response, index int) string {
	return self.RuleTree.Nodes[resp.GetRuleName()].OutFeild[index]
}
Exemplo n.º 2
0
// 用指定规则解析响应流
func (self *Spider) CallRule(ruleName string, resp *context.Response) {
	resp.SetRuleName(ruleName)
	self.GoRule(resp)
}
Exemplo n.º 3
0
// 根据响应流运行指定解析Rule,仅用于crawl模块,Rule中请使用Parse()代替
func (self *Spider) ExecParse(resp *context.Response) {
	self.RuleTree.Trunk[resp.GetRuleName()].ParseFunc(self, resp)
}
Exemplo n.º 4
0
// 根据响应流运行指定解析规则,不推荐在规则中使用
func (self *Spider) GoRule(resp *context.Response) {
	self.RuleTree.Nodes[resp.GetRuleName()].ParseFunc(self, resp)
}
Exemplo n.º 5
0
// 调用指定Rule下解析函数ParseFunc(),解析响应流
func (self *Spider) Parse(ruleName string, resp *context.Response) {
	resp.SetRuleName(ruleName)
	self.ExecParse(resp)
}