if "Login" in key: break value = span.getText().split(':')[1].replace("\n", "").strip() # setters # if not mechanics type then must be general type if "Mechanics" in key: newExercise.set_mechanics(value) elif "Type" in key: newExercise.set_type(value) if "Equipment" in key: newExercise.set_equipment(value) if "Force" in key: newExercise.set_force(value) if "Level" in key: newExercise.set_level(value) if "Main" in key: newExercise.set_muscle(value) if "Other" in key: newExercise.set_other_muscles(value) if "Sport" in key: newExercise.set_sport(value) exercises.append(newExercise) # json dump and print to console every exercise for exercise in exercises: with open('exerciseBible.json', 'w') as fp: json.dump(exercise.__dict__, fp, sort_keys=True)