def get_course_id(self):
# Link below retrieves JSON file with course information based on course name
base_url = "https://www.coursera.org/api/onDemandCourses.v1?q=slug&slug="
# Paste
url_tmp = base_url + self.course_slug
# GET
resp = requests.get(url_tmp)
# If not ok
if not resp.ok:
# Log event
if self.log:
logging.error("Cannot fetch course id ({})".format(self.course_slug))
raise ApiResolve("Server returned {}. Check whether course name is correct.".format(str(resp)))
json_data = resp.json()
# Get courseID
course_id = json_data["elements"][0]["id"]
# Return
self.course_id = course_id
评论列表
文章目录