Home > Software design >  Python get data from MySchoolMenus.com
Python get data from MySchoolMenus.com

Time:10-12

I'm trying to get the lunch menu for my school, which is on MySchoolMenus.com. I'm using the python request module. When I do

r = request.get("https://www.myschoolmenus.com/instance/473/district/463/school/3915/menu/22927")
print(r.content)

It only returns the HTML non of the lunch options.

CodePudding user response:

You can get the data from the following API:

GET https://www.myschoolmenus.com/api/v1/public/menu/{menu_id}

It also need the x-district header with the same district value as in the url path, in this case 463

The following code retrieves the data:

import requests

r = requests.get(
    "https://www.myschoolmenus.com/api/v1/public/menu/22927",
    headers={
        "x-district": "463"
    })

print(r.json()["data"])
  • Related