summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2024-02-21 21:51:12 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2024-02-21 21:51:12 +0100
commitba009a9949a007a03e2e966e285f463a5ff4b758 (patch)
tree69b3d0df3fa83814cdbc2043a0e40aabee7abfe6
parente2e0ed8fa7d26a23f77b378907b3f902be9e028e (diff)
Remove the setup function while we can
-rw-r--r--README.md5
-rw-r--r--flyscrape.go2
-rw-r--r--js.go6
-rw-r--r--scrape.go5
4 files changed, 0 insertions, 18 deletions
diff --git a/README.md b/README.md
index f242168..94f013f 100644
--- a/README.md
+++ b/README.md
@@ -238,11 +238,6 @@ export const config = {
},
};
-export function setup() {
- // Optional setup function, called once before scraping starts.
- // Can be used for authentication.
-}
-
export default function ({ doc, url, absoluteURL }) {
// doc - Contains the parsed HTML document
// url - Contains the scraped URL
diff --git a/flyscrape.go b/flyscrape.go
index 057eb08..ce7c51f 100644
--- a/flyscrape.go
+++ b/flyscrape.go
@@ -49,7 +49,6 @@ func Run(file string, overrides map[string]any) error {
scraper := NewScraper()
scraper.ScrapeFunc = exports.Scrape
- scraper.SetupFunc = exports.Setup
scraper.Script = file
scraper.Client = client
scraper.Modules = LoadModules(cfg)
@@ -96,7 +95,6 @@ func Dev(file string, overrides map[string]any) error {
scraper := NewScraper()
scraper.ScrapeFunc = exports.Scrape
- scraper.SetupFunc = exports.Setup
scraper.Script = file
scraper.Client = client
scraper.Modules = LoadModules(cfg)
diff --git a/js.go b/js.go
index 1f0d600..db2c261 100644
--- a/js.go
+++ b/js.go
@@ -55,12 +55,6 @@ func (e Exports) Scrape(p ScrapeParams) (any, error) {
return fn(p)
}
-func (e Exports) Setup() {
- if fn, ok := e["setup"].(func(goja.FunctionCall) goja.Value); ok {
- fn(goja.FunctionCall{})
- }
-}
-
type Imports map[string]map[string]any
func Compile(src string, imports Imports) (Exports, error) {
diff --git a/scrape.go b/scrape.go
index f09cba6..cb7f18c 100644
--- a/scrape.go
+++ b/scrape.go
@@ -53,7 +53,6 @@ func NewScraper() *Scraper {
type Scraper struct {
ScrapeFunc ScrapeFunc
- SetupFunc func()
Script string
Modules []Module
Client *http.Client
@@ -97,10 +96,6 @@ func (s *Scraper) Run() {
}
}
- if s.SetupFunc != nil {
- s.SetupFunc()
- }
-
go s.scrape()
s.wg.Wait()
close(s.jobs)