(ssg-wsg)是否可以从api获取完整的课程参考号?

时间:2020-03-19 00:31:00

标签: api

如标题中所述,网站上有200,000多门课程。.我使用了带有代码和日期的api,但只能从目录中提取多达400门课程...有什么办法吗?获取所有课程参考号?

下面是我的代码

tagging_codes=[30011,30012,30013,30021,30022,30031,30032,30033,30041,30042,30043,
               30051,30052,30053,30061,30062,30063,30071,30072,30073,30081,30082,
               30083]
full_list=[]
section=['directory?pageSize=20&page='+str(num+1)+'&taggingCodes='+str(i)+'&courseSupportEndDate=20201223&retrieveType=FULL' for num in range(20) for i in tagging_codes]
for i in section:
    res=requests.get('https://public-api.ssg-wsg.sg/courses/'+i,headers={'Authorization':'Bearer '+token_value})
    soup=res.json()
    try:
        data=soup['data']['courses']
    except:
        continue
    for j in range(len(data)):
        full_list.append(data_dict_maker(data,j))
        # generate sleep
    sleep_duration = random.randint(2,6)
    print(sleep_duration, i, j)
    time.sleep(sleep_duration) 

1 个答案:

答案 0 :(得分:0)

我检查了Retrieve Courses API的API响应有效负载,并且能够检索到20,000多个课程,而不是您提到的400个课程。 MySkillsFuture的课程搜索也显示了总计约21k的课程。可以共享使用的输入参数是什么?