-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic scope engine.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dynamic | ||
|
||
import ( | ||
"github.com/projectdiscovery/gologger" | ||
"github.com/projectdiscovery/katana/pkg/engine/common" | ||
"github.com/projectdiscovery/katana/pkg/tfidf" // Import the new tfidf package | ||
"github.com/projectdiscovery/katana/pkg/types" | ||
errorutil "github.com/projectdiscovery/utils/errors" | ||
) | ||
|
||
var ( | ||
tfidfModel *tfidf.TfIdf | ||
similarityThreshold float64 = 0.7 | ||
) | ||
|
||
// Crawler is a dynamic crawler instance | ||
type Crawler struct { | ||
*common.Shared | ||
} | ||
|
||
// New returns a new dynamic crawler instance | ||
func New(options *types.CrawlerOptions) (*Crawler, error) { | ||
shared, err := common.NewShared(options) | ||
if err != nil { | ||
return nil, errorutil.NewWithErr(err).WithTag("dynamic") | ||
} | ||
tfidfModel = tfidf.New() | ||
return &Crawler{Shared: shared}, nil | ||
} | ||
|
||
// Close closes the crawler process | ||
func (c *Crawler) Close() error { | ||
return nil | ||
} | ||
|
||
// Crawl crawls a URL with the specified options | ||
func (c *Crawler) Crawl(rootURL string) error { | ||
crawlSession, err := c.NewCrawlSessionWithURL(rootURL) | ||
if err != nil { | ||
return errorutil.NewWithErr(err).WithTag("dynamic") | ||
} | ||
defer crawlSession.CancelFunc() | ||
gologger.Info().Msgf("Started dynamic crawling for => %v", rootURL) | ||
if err := c.Do(crawlSession, c.makeRequest); err != nil { | ||
Check failure on line 44 in pkg/engine/dynamic/dynamic.go
|
||
return errorutil.NewWithErr(err).WithTag("dynamic") | ||
} | ||
return nil | ||
} |