TumblrImageDownloader

TumblrImageDownloader

This class contains methods that can download photos from a Tumblr blog.

Constructor

new TumblrImageDownloader(options)

Source:
Creates a `TumblrImageDownloader` object.
Parameters:
Name Type Description
options TumblrImageDownloaderOptions Options that can be passed to the constructor. All are optional.

Extends

  • EventEmitter

Members

agent

Source:
The agent that will be used with each request.

cookies

Source:
The cookies that will be sent with each request.

headers :Object

Source:
The headers that will be sent with all non-xhr requests.
Type:
  • Object

jar :RequestJar

Source:
The request `jar` object that will be used with each request. Is a wrapper for TumblrImageDownloader#cookies so that `TumblrImageDownloader.cookies == TumblrImageDownloader.jar._jar`.
Type:
  • RequestJar

login_form_template :Object

Source:
The login form that will be posted when TumblrImageDownloader#login is called, excluding the credentials and CSRF.
Type:
  • Object

mobile_user_agent :string

Source:
Default Value:
  • TUMBLR_MOBILE_USER_AGENT;
The user-agent that will be used with XHR requests.
Type:
  • string

request :Object

Source:
request-promise-any object that will be used for each request.
Type:
  • Object

user_agent :string

Source:
Default Value:
  • TUMBLR_USER_AGENT;
The user-agent that will be used with each desktop request.
Type:
  • string

Methods

(async) downloadPhoto(url) → {Promise.<ClientResponse>}

Source:
Downloads an individual photo from a Tumblr blog.
Parameters:
Name Type Description
url string URL of the photo to download.
Returns:
- HTTP Response.
Type
Promise.<ClientResponse>

(async) getLoginForm() → {Promise.<Object>}

Source:
Retrieves the login form from the Tumblr login page and extracts the CSRF token. Returns the TumblrImageDownloader#login_form_template object with the CSRF token set to `form_key`.
Returns:
- The Tumblr login form.
Type
Promise.<Object>

(async) getPhotos(blogSubdomain, pageNumberopt) → {Promise.<Array.<Photo>>}

Source:
Retrieves all photos on a page of a blog.
Parameters:
Name Type Attributes Default Description
blogSubdomain string Subdomain of the blog.
pageNumber number <optional>
1 Page number of the blog.
Returns:
Type
Promise.<Array.<Photo>>

(async) getPhotoset(url) → {Promise.<Array.<PhotosetPhoto>>}

Source:
Returns the photos in a photoset.
Parameters:
Name Type Description
url string URL of the photoset.
Returns:
- The photos in the photoset.
Type
Promise.<Array.<PhotosetPhoto>>

(async) login(username, password) → {Promise.<TumblrLoginResponse>}

Source:
Login to the Tumblr account using the provided credentials.
Parameters:
Name Type Description
username string The username to use.
password string The password to use.
Returns:
Type
Promise.<TumblrLoginResponse>

(async) postLoginForm(form)

Source:
Posts the login form.
Parameters:
Name Type Description
form Object The Tumblr login form.

(async) scrapeBlog(options) → {Promise|Promise.<Array.<Photo>>}

Source:
Iterates through all pages in a blog. By default photos are emitted via the TumblrImageDownloader#photo event and not resolved with the Promise. Set `optioons.returnPhotos` to `true` to return photos.
Example
let downloader = new TumblrImageDownloader();
downlaoder.on('photo', () => { 'do something with photo' });
downloader.scrapeBlog({ blogSubdomain: 'blah' });
Parameters:
Name Type Description
options ScrapeBlogOptions Options that can be used with this method.
Returns:
Type
Promise | Promise.<Array.<Photo>>

Events

end

Source:
Fires when the scraper has scrapped all pages.

error

Source:
Fires if an error occurs during scraping.
Type:
  • Error

pageChange

Source:
Fires when the scraper has moved on to the next page.
Type:

photo

Source:
Fires when a photo has been scraped.
Type: