新增--distance参数, 控制simhash阈值

This commit is contained in:
M09Ic 2022-11-10 21:26:07 +08:00
parent 5fdbd5e05d
commit 9b99c2a0b2
2 changed files with 12 additions and 5 deletions

View File

@ -47,10 +47,11 @@ type OutputOptions struct {
} }
type RequestOptions struct { type RequestOptions struct {
Headers []string `long:"header"` Headers []string `long:"header"`
Method string `long:"method"` Method string `long:"method"`
Cookie string `long:"cookie"` Cookie string `long:"cookie"`
Force bool `long:"force"` Force bool `long:"force"`
SimhashDistance int `long:"distance"`
} }
type MiscOptions struct { type MiscOptions struct {
@ -99,6 +100,10 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
logs.Log.Writer = r.Progress.Bypass() logs.Log.Writer = r.Progress.Bypass()
} }
if opt.SimhashDistance != 0 {
pkg.Distance = uint8(opt.SimhashDistance)
}
if opt.Force { if opt.Force {
breakThreshold = 999999 breakThreshold = 999999
} }

View File

@ -116,9 +116,11 @@ func (bl *Baseline) Compare(other *Baseline) int {
return -1 return -1
} }
var Distance uint8
func (bl *Baseline) FuzzyCompare(other *Baseline) bool { func (bl *Baseline) FuzzyCompare(other *Baseline) bool {
// todo 模糊匹配 // todo 模糊匹配
if parsers.SimhashCompare(other.BodySimhash, bl.BodySimhash) < 3 { if parsers.SimhashCompare(other.BodySimhash, bl.BodySimhash) < Distance {
return true return true
} }
return false return false