https://github.com/dotnize/moodle-scrape
Easily scrape data from Moodle LMS sites
https://github.com/dotnize/moodle-scrape
javascript lms moodle moodle-scrape moodle-scraper nodejs scraper web-scraper webscraper
Last synced: 3 months ago
JSON representation
Easily scrape data from Moodle LMS sites
- Host: GitHub
- URL: https://github.com/dotnize/moodle-scrape
- Owner: dotnize
- License: mit
- Created: 2022-08-30T15:47:58.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-25T12:14:45.000Z (almost 3 years ago)
- Last Synced: 2025-05-01T17:11:47.819Z (about 1 year ago)
- Topics: javascript, lms, moodle, moodle-scrape, moodle-scraper, nodejs, scraper, web-scraper, webscraper
- Language: TypeScript
- Homepage: https://moodle-scrape.nize.foo
- Size: 27.3 KB
- Stars: 15
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# moodle-scrape
[](https://www.npmjs.com/package/moodle-scrape)
[](https://moodle-scrape.nize.foo)
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 },
});
// ...
```