# 9gag

> Download 9GAG posts and comments

Latest version **4.0.0** (published 2020-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install 9gag
pnpm add 9gag
yarn add 9gag
bun add 9gag
```

Provides the command `9gag`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2020-06-09 |
| First published | 2017-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 991 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Rui Almeida |
| Maintainers | ruial |
| Keywords | 9gag, scrapper, offline, cache |

## Links

- npm: https://www.npmjs.com/package/9gag
- Repository: https://github.com/ruial/9gag
- Issues: https://github.com/ruial/9gag/issues
- npm.io page: https://npm.io/package/9gag

## Dependencies (3)

- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.3
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2020-06-09
- 3.2.1 — 2020-03-28
- 3.2.0 — 2020-03-28
- 3.1.0 — 2020-03-27
- 3.0.0 — 2020-03-27
- 2.0.1 — 2018-10-21
- 2.0.0 — 2017-11-05
- 1.0.2 — 2017-02-09
- 1.0.1 — 2017-02-09
- 1.0.0 — 2017-02-09

## README

# 9gag

A Node.js package to download 9GAG posts and comments.

It can be used as a module to scrap memes or as a command line application to save data to a local folder and generate an HTML file for offline use.

Node.js 8 or above required due to Async/Await usage.

## Install

    npm install 9gag

## Examples

### CLI

    9gag <post_count> [<folder> default:output] [<section> default:hot] [<comment_count> default:0]
    9gag 10
    9gag 20 output trending 3

## Testing

    # unit
    npm run test:unit
    # unit + integration
    npm test

### Scrap posts and comments with images

    const NineGag = require('9gag');
    const Scraper = NineGag.Scraper;
    const Downloader = NineGag.Downloader;

    async function memes() {
        try {
            // number of posts, section and number of comments
            // can pass a custom http client as the last Scraper argument
            const scraper = new Scraper(10, 'hot', 3);
            const posts = await scraper.scrap();
            posts.forEach(p => console.log(`${p.title} -> ${p.content} -> ${p.comments.map(c => c.content)[0]}`));
            await new Downloader('output').downloadPosts(posts);
        }
        catch (err) {
            console.error(err);
        }
    }

    memes();

### HTML output

![demo](demo.png)

---
_Source: https://npm.io/package/9gag · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
