Giter Site home page Giter Site logo

josfranmc / jgutenbergdownload Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.31 MB

This software allows you to download books from the Gutenberg project repositories.

License: GNU General Public License v3.0

Java 85.36% HTML 14.64%
java scraping gutenberg-ebooks ebooks

jgutenbergdownload's Introduction

JGutenbergDownload

This software allows you to download books from the Gutenberg project repositories.

The Gutenberg project website is intended for human users only. If you want to download many books using an automated tool like this, keep in mind that your ip address can be blocked temporarily or permanently.
The Gutenberg project is a solidarity project based on the hard work of thousands of volunteers. So please, don't abuse.

License: GPL v3

Getting Started

The project is a Maven project, so you can import it in your favorite IDE as any other Maven project.

mvn install

will install the artifact in your local repository, being ready to be used as a dependency in any project:

<dependency>
  <groupId>org.josfranmc.gutenberg</groupId>
  <artifactId>JGutenbergDownload</artifactId>
  <version>2.1.2</version>
</dependency>

When you build the project with Maven you get two jars in the target directory: JGutenbergDownload-2.1.2.jar and JGutenbergDownload-2.1.2-shaded.jar. The first one is the standard jar of the project. The second one is an uber jar with all necessary dependencies, which is suitable to use from command line.

Download the latest uber jar from Releases.

The project was developed with openjdk 11. Jar files should run without problems with a jre 1.8 or higher.

Usage

The main class to use is JGutenbergDownload, which offers some methods to set up the download process.

The following code will download 20 english books in a folder called mybooks:

try {
    JGutenbergDownload jg = new JGutenbergDownload();
    jg.setLanguage("en");
    jg.setSavePath("mybooks");
    jg.setMaxFilesToDownload(20);
    jg.downloadBooks();
} catch(GutenbergException e) {
    System.err.println(e.getMessage());
}

You can also use the DownloadParams class to set up:

try {
    DownloadParams params = new DownloadParams();
    params.setLanguage("en");
    params.setSavePath("mybooks");
    params.setMaxFilesToDownload(20);
    
    JGutenbergDownload jg = new JGutenbergDownload();
    jg.setParameters(params);
    jg.downloadBooks();
} catch(GutenbergException e) {
    System.err.println(e.getMessage());
}

Finally, you can execute the JGutenbergDownload's main method by passing the setting options as argument. The following code perfoms the same function as the previous ones:

try {
    String[] args = {"-l", "en", "-s", "mybooks", "-m", "20" };
    JGutenbergDownload.main(args);
} catch(GutenbergException e) {
    System.err.println(e.getMessage());
}

These are the options you can use as arguments:

-f xxx (xxx type of files to download, default: txt)
-l xx  (xx  language of books to download, default: es)
-s xxx (xxx download path on local machine, default: program folder)
-d xxx (xxx delay between downloads in milliseconds, default 2000)
-m xx  (xx  max number of downloads (default 10, 0 for download all)
-o     (    overwrite existing files, default: false)
-z     (    don't unzip downloads, default: true)
(only -h to show options list);

It is possible to run the program from the command line. To this purpose, you may use the JGutenbergDownload-2.1.2-shaded.jar package with any of the options above:

java -jar JGutenbergDownload-2.1.2-shaded.jar -l en -s mybooks -m 20

License

GPLv3 or later, see LICENSE for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.