Started and almost completed Mizuno Script

This commit is contained in:
Norm Rasmussen
2023-04-03 17:16:01 -04:00
parent 478b21c8ef
commit 9ef9e63297
3 changed files with 70 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import Apikeys
apiKey = Apikeys.walmartprod
course_dict = {}
def get_course():
count = 0
courses = []
@ -22,11 +23,11 @@ def get_course():
uuid = response["id"]
name = response["attributes"]["name"]
course_dict = {
"id": uuid,
"name": name,
"status": status,
"url": f"https://walmart.northpass.com/app/courses/{uuid}"
}
"id": uuid,
"name": name,
"status": status,
"url": f"https://walmart.northpass.com/app/courses/{uuid}",
}
# FIX: Up until here, each course gets read to the terminal.
# FIX: After this, something is being overwritten.
@ -37,6 +38,7 @@ def get_course():
if "next" not in nextlink:
break
def get_cat_name(cat_id, course_dict, courses):
headers = {"accept": "application/json", "X-Api-Key": apiKey}
cats = []
@ -61,7 +63,6 @@ def get_cat_name(cat_id, course_dict, courses):
cats.append(cat_name)
course_dict.update({"categories": cats})
try:
courses.append(course_dict)
except TypeError as e:
@ -74,5 +75,6 @@ def write_to_csv(courses):
df = pd.DataFrame.from_dict(courses)
df.to_csv("/Users/normrasmussen/Downloads/walmart_courses.csv")
if __name__ == "__main__":
get_course()