Skip to content
Doğan Çelik edited this page Aug 20, 2015 · 15 revisions

endl.page(url, options)

If options.pageUrlAsReferrer is true then url is used as Referrer, if you set something to options.previousUrl, it's used instead.

To change headers, change options.headers.

Returns: extractorInstance

extractorInstance

Function name Returns Info
find(query, callback) containerPromise Same as querySelectorAll
findXpath(query, callback) containerPromise Same as evaluate

To get containerInstance you need to do this:

endl
  .page(url)
  .find('a')
  .then(function(containerInstance) {
    // do stuff with the container here
  });

containerInstance

Function name Returns Info
page(attrName, options) extractorInstance Creates an extractorInstance of href() or attrName of the container
attr(attrName, index) attrInstance Select the attribute of the element
href() attrInstance Shortcut for attr('href')
text() attrInstance Select the text of the element
all(attrName) array of attrInstance Returns an array of attr(attrName)
index(index) containerInstance Selects an element from the array (if there is an array)
download(options) fileInstance Shortcut for href().download()

Notice: It can contain more than one element, use attr(), href(), download() wisely. If you use attr('href') in a 10-element container, it will select the first element's href.

attrInstance

Function name Returns Info
page(options) extractorInstance Creates an extractorInstance of attrInstance's value
download(options) fileInstance Creates a fileInstance and downloads the link
value(newValue) string Gets or sets attribute value of Attr instance.

fileInstance

Function name Returns Info
download(options, callback) fileInstance Creates a fileInstance and downloads the link
extract(options, callback) fileInstance Extracts a ZIP file
execute(options) fileInstance Executes the file

download() options

Option name Takes Info
headers object Headers for GET request
pageUrlAsReferrer boolean Uses page URL as Referer header
filenameMode object Every option under filenameMode is boolean except predefined is a string: contentDisposition, urlBasename, contentType, predefined, redirect
directory string Download directory, default is current working directory.

extract() options

Option name Takes Info
to string Extraction directory.
cd string Change directory of ZIP. Defaults to false.
cdRegex string Same as cd but acts like a RegExp defaults to false.
fileGlob glob string Example: *.js will only extract .js files
maintainEntryPath boolean Defaults to true.
overwrite boolean Overwrite extracted files. Defaults to true.

endl.file(url, pageUrl)

Create a fileInstance without going through endl.page(). pageUrl is optional.

endl.load(filepath)

See Parser page.