eklem / browsercrawler

Crawling content from a site within the browser. A basis for i.e. a search solution for static sites.
https://eklem.github.io/browsercrawler/doc/
MIT License
2 stars 0 forks source link

selectors config file #11

Open eklem opened 6 years ago

eklem commented 6 years ago

Split out the selectors config to a .json-file so it's less scary to make it match your content. Should be required in the main.js file

eklem commented 6 years ago

Skip the require-step and just fetch the JSON file with the fetch API. Format of setup.json can be like this:

{
  "urls": [
    "https://example.com/1",
    "https://example.com/2",
    "https://example.com/3"
  ],
  "selectors": {
    "title": "$('title').text()",
    "body": "$('body').text()"
  }
}
eklem commented 6 years ago

Not a config file, but the crawler should take it as input, so a setup/config step

eklem commented 6 years ago

https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript