Exemple #1
0
    def get_course_data(self, objectid):

        uri = "https://mooc1-1.chaoxing.com/ananas/status/%s?k=2041&flag=normal&_dc=%d" % (
            objectid, get_timestamp())

        r = self.s.get(uri)

        return json.loads(r.text)
Exemple #2
0
    def getCode(self, name):
        uri = "http://passport2.chaoxing.com/num/code?" + str(get_timestamp())

        r = self.s.get(uri)

        with open(name, 'wb') as fd:
            for chunk in r.iter_content():
                fd.write(chunk)
Exemple #3
0
    def updata_log_ppt(self, jobId, knowledgeid, courseId, clazzid, jtoken):

        uri = "https://mooc1-1.chaoxing.com/ananas/job/document?jobid=%s&knowledgeid=%s&courseid=%s&clazzid=%s&jtoken=%s&_dc=%d" % (
            jobId, knowledgeid, courseId, clazzid, jtoken, get_timestamp())

        r = self.s.get(uri)

        j = json.loads(r.text)
        print(j['msg'])
        return j['status']
Exemple #4
0
    def get_list(self):
        uri = "http://i.mooc.chaoxing.com/space/index?t=" + \
            str(get_timestamp())

        r = self.s.get(uri)

        rule = r'<iframe src=\"(.*?)\"'
        d = re.findall(rule, r.text)

        for it in d:
            if it != "":
                uri = it
                break

        r = self.s.get(uri)

        rule = r'<li style=\"position:relative\">(.*?)</li>'
        d = re.findall(rule, r.text, re.DOTALL)

        ret = []

        for item in d:
            item = html.unescape(item)

            url = re.findall(r'href=\'(.*?)\'', item)
            courseId = re.findall(r'courseId" value=\"(.*?)\"', item)
            classId = re.findall(r'classId" value=\"(.*?)\"', item)
            cpi = re.findall(r'cpi=(.*?)&', url[0])
            title = re.findall(
                r'<div class=\"Mconright httpsClass\">(.*?)</div>', item,
                re.DOTALL)

            infomation = re.findall(r'title=\"(.*?)\"', title[0])

            course = {
                'courseId': courseId[0],
                'classId': classId[0],
                'cpi': cpi[0],
                'url': "https://mooc1-1.chaoxing.com" + url[0],
                'courseName': infomation[0],
                'teachar': infomation[1],
                'school': infomation[2],
                'class': infomation[3]
            }

            ret.insert(len(ret), course)

        return ret
Exemple #5
0
    def get_task_page(self, id, courseid):

        _time = str(get_timestamp())
        enc = "token={0}&_time={1}&DESKey={2}".format(self.token, _time,
                                                      "Z(AfY@XS")
        enc = hashlib.md5(enc.encode("utf-8")).hexdigest()

        url = "https://mooc1-api.chaoxing.com/gas/knowledge?id={0}&courseid={1}&fields=name,id,card.fields(id,title,cardorder,description)&view=json&token={2}&_time={3}&inf_enc={4}" \
            .format(id, courseid, self.token, _time, enc)

        r = self.s.get(url)

        if r.text != "":
            o = json.loads(r.text)
            if len(o['data']) != 0:
                return o['data'][0]['card']['data']

        return None
Exemple #6
0
    def update_log_video(self, reportUrl, clazzId, playingTime, duration,
                         dtoken, objectId, otherInfo, jobId, userid):
        clipTime = "0_%s" % duration
        enc = "[{0}][{1}][{2}][{3}][{4}][{5}][{6}][{7}]".format(
            clazzId, userid, jobId, objectId, playingTime * 1000,
            "d_yHJ!$pdA~5", duration * 1000, clipTime)

        uri = "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}{17}{18}{19}{20}{21}{22}{23}{24}{25}{26}{27}{28}".format(
            reportUrl, "/", dtoken, "?clazzId=", clazzId, "&playingTime=",
            playingTime, "&duration=", duration, "&clipTime=", clipTime,
            "&objectId=", objectId, "&otherInfo=", otherInfo, "&jobid=", jobId,
            "&userid=", userid, "&isdrag=", 0, "&view=pc", "&enc=",
            hashlib.md5(enc.encode(encoding='UTF-8')).hexdigest(), "&rt=", 0.9,
            "&dtype=Video", "&_t=", get_timestamp())

        r = self.s.get(uri)

        ret = json.loads(r.text)

        return ret['isPassed']
Exemple #7
0
    def get_user_info(self):
        r = self.s.get(
            "https://sso.chaoxing.com/apis/login/userLogin4Uname.do")
        if r.text != "":
            o = json.loads(r.text)
            if o['result'] == 1:
                puid = o['msg']['puid']
                _time = str(get_timestamp())
                enc = "token={0}&_time={1}&puid={2}&myPuid={3}&DESKey={4}".format(
                    self.token, _time, puid, puid, "Z(AfY@XS")
                enc = hashlib.md5(enc.encode("utf-8")).hexdigest()
                url = "https://useryd.chaoxing.com/apis/user/getUser?token={0}&_time={1}&puid={2}&myPuid={3}&inf_enc={4}".format(
                    self.token, _time, puid, puid, enc)
                r = self.s.get(url)
                if r.text != "":
                    o = json.loads(r.text)
                    if o['result'] == 1:
                        self.uid = o['msg']['puid']
                        return o['msg']

        return None