1.0.5 • Published 7 years ago

alis-request v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

alis-request

Scraper api to get book by years on alis library

Installing

npm

npm install alis-request --save

yarn

yarn add alis-request

API

  • ReadableStreamBooks - read all book by year in stream
  • sendInitialQuery - make initial http query
  • getPage - get page body
  • getNumberedPageUrls - get ten page urls
  • run - recursive runner

Examples

You can do what you want with books, for example save in database. Next example return all books 2015 year in stream.

import Stream from 'stream';
import { sendInitialQuery, getPage, getNumberedPageUrls, run, ReadableStreamBooks } from 'alis-request';

const WritableStreamBooks = new Stream.Writable();
ReadableStreamBooks.pipe(WritableStreamBooks);

const books = [];

const initParams = {
  year: 2015,
  ip: '86.57.174.45',
};

sendInitialQuery(initParams, (err, res) => {
  if (err) {
    console.log(err);
    return;
  }
  const firstTenPageUrls = getNumberedPageUrls(res.page, initParams.ip);
  run(getPage, firstTenPageUrls, initParams.ip, res.jar);
});

WritableStreamBooks._write = (book, encoding, done) => {
  books.push(book);
  console.log(`STREAM: ${books.length}`);
  // ready to process the next chunk
  done();
};

Built With

  • request - Simplified HTTP client
  • cheerio - Fast, flexible & lean implementation of core jQuery designed specifically for the server.

Authors

License

MIT License

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago