MensaMax-API
mensadigital.de
/ mensamax.de
/ mensapoint.de
)
Scraper for MensaMax products (like π²π₯π₯‘πππ¦π₯ π΄π½οΈ this is just a fancy way of getting some food π½οΈπ΄ π²π₯π₯‘πππ¦π₯
π§ Usage
General Note: Please use your own caching strategy, MensaMax servers might be quite slow
API usage
see https://mensa.vercel.app/institutions-ui for API URLs
npm package usage
Install package
pnpm i @philippdormann/mensamax-api
ts/ module imports
import { fetchHTML, parser } from '@philippdormann/mensamax-api';
const html = await fetchHTML({ p: 'FO111', e: 'herz', kw: 15 });
const parsed = await parser(html);
console.log(parsed);
CommonJS imports
const { fetchHTML, parser } = require('@philippdormann/mensamax-api');
(async function () {
try {
const html = await fetchHTML({ p: 'FO111', e: 'herz', kw: 15 });
const parsed = await parser(html);
console.log(parsed);
} catch (e) {
console.log(e);
}
})();
π Deployment
This project is deployed as a serverless function on the url https://mensa.vercel.app with Vercel βοΈ
π³ Docker Deployment
This project can be deployed as a docker container. To do so, just run this code:
docker-compose up -d --build
π» Local Development
Either develop on your machine directly or use the provided devcontainer for VSCode
pnpm i
pnpm dev
π‘ How this works
- Fetch data from url (fetcher.js)
- fetch
VIEWSTATE
+VIEWSTATEGENERATOR
from .NET with axios- hit login endpoint with a GET request
- request method: POST
- enable followAllRedirects
- set login headers
- setup request (these settings are important)
- enable cookies
- request method: POST
- enable followAllRedirects
- set login headers
- fetch
- Parsing the data (parser.js)
- get relevant elements with cheerio
- timePeriod
- categories
- day cards with food items
- minify html
- Regex
- Replace unreadable markup such as internal MensaMax IDs
- Build JSON from custom markup
- get relevant elements with cheerio
- Serve via rayo http/ Vercel Serverless Function
π« Known/ tested institutions
- For a nice GUI version, see https://mensa.vercel.app/institutions-ui
- For the raw data, see institutions.json
- Please feel free to suggest new institutions by opening a PR/ Issue
π§ General Knowledge
- For some reason, MensaMax IT department decided to have many URLs
- you can find a list of all known MensaMax URLS @mensamax-urls.txt
- These URLs are not interchangeable and seem to be different MensaMax versions (as of 13.04.2023)
- There is a private/ internal GraphQL API for MensaMax which needs authentication
ππ° Support this project
You like this project and would like to give something back? Thanks! Have a look at my profile for more information & options.