# moodle-scrape

> Scrape data from Moodle sites

Latest version **3.1.5** (published 2023-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install moodle-scrape
pnpm add moodle-scrape
yarn add moodle-scrape
bun add moodle-scrape
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.5 |
| Published | 2023-08-25 |
| First published | 2022-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Nathaniel Tampus |
| Maintainers | n9ze |

## Links

- npm: https://www.npmjs.com/package/moodle-scrape
- Repository: https://github.com/99nize/moodle-scrape
- Homepage: https://moodle-scrape.nize.foo
- Issues: https://github.com/99nize/moodle-scrape/issues
- npm.io page: https://npm.io/package/moodle-scrape

## Dependencies (1)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.12

## Recent versions

- 3.1.5 (latest) — 2023-08-25
- 3.1.4 — 2023-06-28
- 3.1.3 — 2023-06-28
- 3.1.2 — 2023-06-28
- 3.1.1 — 2023-06-28
- 3.1.0 — 2023-02-01
- 3.0.0 — 2023-01-31
- 2.0.1 — 2022-08-31
- 2.0.0 — 2022-08-30
- 1.0.1 — 2022-03-09
- 1.0.0 — 2022-03-09

## README

# moodle-scrape

[![NPM](https://nodei.co/npm/moodle-scrape.png)](https://www.npmjs.com/package/moodle-scrape)<br>
[![Docs](https://img.shields.io/github/actions/workflow/status/99nize/moodle-scrape/static.yml?branch=main&label=docs&logo=github)](https://moodle-scrape.nize.foo)<br>
Easily scrape data from Moodle sites. Tested on Moodle v3.8.

### Features:

- [x] user info
- [x] courses
- [x] tasks/deadlines/events
- [ ] course files/resources ([#1](https://github.com/99nize/moodle-scrape/issues/1))

# Installation

```sh
npm install moodle-scrape
```

```js
const { Moodle } = require("moodle-scrape"); // CommonJS
// or
import { Moodle } from "moodle-scrape"; // ESM
```

# Usage

```js
const moodle = new Moodle(fetch, "https://examplesite.com");

await moodle.login("supercoolusername", "superCoolpassword123");
// returns true if login was successful

console.log(moodle.user.name); // string
console.log(moodle.courses); // array of course objects
console.log(moodle.tasks); // array of task objects
```

or view the [example](example/index.js) CommonJS script

### Scraping manually

After calling `.login()`, the `cookies` property gets filled with a string containing your cookies which you can pass to your own fetch method. For example:

```js
await moodle.login("username", "password");

const res = await fetch("https://examplesite.com", {
  headers: { cookie: moodle.cookies },
});
// ...
```

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