-
Notifications
You must be signed in to change notification settings - Fork 1
API
Doğan Çelik edited this page Aug 20, 2015
·
15 revisions
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
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
});
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.
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. |
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 |
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. |
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. |
Create a fileInstance without going through endl.page()
. pageUrl is optional.
See Parser page.