-
Notifications
You must be signed in to change notification settings - Fork 1
Parser
Doğan Çelik edited this page Aug 17, 2015
·
5 revisions
I implemented Parser inside endl itself. I haven't moved it to endl-cli yet. Because I want other people to use this feature without downloading endl-cli.
endl.load(object|filePath, downloadCallback, extractCallback)
You can use Parser through endl.load().
It accepts 3 arguments, downloadCallback and extractCallback are optional.
You can pass a JavaScript object or a YAML file path or a JSON file path to the object argument.
Then endl will automatically run your object or file.
endl.load() has differences to the main module functions.
I'm going to list every object property you can use in endl.load()
{
url: # your page URL
find: # your jQuery selector
findIndex: # index >= 0
findType: # 'cheerio' or 'xpath', default is 'cheerio'
then: # all options you see in root object can be used here too (this is recursive)
attr: # which attribute of element to use - defaults to 'href'
useText: # if this is true, it will use text() of element instead of attr()
filename: # shortcut to filenameMode.predefined
filenameMode: # this is an array ['urlBasename, 'contentType', 'contentDisposition', 'redirect']
directory: # directory to save to
execute: # an array of arguments or an execFile options object (see Node.js docs for that)
extract:
to: # where to extract
cd: # change directory inside ZIP
cdRegex: # regex version of cd
fileGlob: # only grab certain files based on glob string
maintainEntryPath: # defaults to true
overwrite: # overwrite files that exist in the extraction folder
}
You can use special variables in directory
and extract.to
:
Currently supported:
-
%tmpdir%
→os.tmpdir()
-
%env:VARNAME%
→ Output of environment variableVARNAME