summaryrefslogtreecommitdiff
path: root/js.go
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2025-01-10 13:09:50 +0100
committerGitHub <noreply@github.com>2025-01-10 13:09:50 +0100
commit40e02d5d28e59dbeb6134afdce12536c602e6aa5 (patch)
tree24c84c4084cf72e552804397eecc9f5bb3c2d4be /js.go
parentbf99c233a18c3165e0d4d251b41224e5bc6eb93d (diff)
Implement manual following (#82)
Diffstat (limited to 'js.go')
-rw-r--r--js.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/js.go b/js.go
index c56ebdb..7446042 100644
--- a/js.go
+++ b/js.go
@@ -30,6 +30,7 @@ type ScrapeParams struct {
HTML string
URL string
Process func(url string) ([]byte, error)
+ Follow func(url string)
}
type ScrapeFunc func(ScrapeParams) (any, error)
@@ -213,6 +214,9 @@ func scrape(vm *goja.Runtime) (ScrapeFunc, error) {
return f(goja.FunctionCall{Arguments: []goja.Value{arg}})
})
+ o.Set("follow", func(url string) {
+ p.Follow(absoluteURL(url))
+ })
return o, nil
}