summaryrefslogtreecommitdiff
path: root/js.go
diff options
context:
space:
mode:
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
}