Skip to content

Commit

Permalink
Create dynamic.go
Browse files Browse the repository at this point in the history
Add dynamic scope engine.
  • Loading branch information
geeknik authored Jun 3, 2024
1 parent 5980eff commit b629a46
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/engine/dynamic/dynamic.go
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

View workflow job for this annotation

GitHub Actions / release-test-windows

c.makeRequest undefined (type *Crawler has no field or method makeRequest)

Check failure on line 44 in pkg/engine/dynamic/dynamic.go

View workflow job for this annotation

GitHub Actions / release-test-linux

c.makeRequest undefined (type *Crawler has no field or method makeRequest)

Check failure on line 44 in pkg/engine/dynamic/dynamic.go

View workflow job for this annotation

GitHub Actions / release-test-mac

c.makeRequest undefined (type *Crawler has no field or method makeRequest)
return errorutil.NewWithErr(err).WithTag("dynamic")
}
return nil
}

0 comments on commit b629a46

Please sign in to comment.