jaryhe 1 год назад
Родитель
Сommit
4a73b7d155
4 измененных файлов с 62 добавлено и 33 удалено
  1. 35 19
      account.txt
  2. 3 3
      common.yaml
  3. 3 0
      record.txt
  4. 21 11
      student/student.go

+ 35 - 19
account.txt

@@ -1,19 +1,35 @@
-2351101200899;Ouchn@19960331;王旭东
-2351101200901;Ouchn@19971009;王绍科
-2351101200902;Ouchn@19810109;王江
-2351101200903;Ouchn@19950830;黄财源
-2351101401935;Ouchn@19891209;马晓华
-2351101401961;Ouchn@19881104;杨小林
-2351101401962;Ouchn@19821020;曾勇
-2351101401963;Ouchn@19970806;许淞浩
-2351101401964;Ouchn@19980524;张婷
-2351101401965;Ouchn@19920807;明智慧
-2351101401966;Ouchn@19920130;刘军
-2351101401967;Ouchn@19900309;孙家美
-2351101401968;Ouchn@19920407;周海燕
-2351101401969;Ouchn@19931225;刘洛灵
-2351101401970;Ouchn@19950507;魏李萍
-2351101401971;Ouchn@19960822;郑乔
-2351101402028;Ouchn@20010513;张霞
-2351101402029;Ouchn@20041018;陈馨雨
-2351101402031;Ouchn@19890213;刘超
+
+2351101402032;Ouchn@19960428;奚伟杰
+2351101402033;Ouchn@19821216;陈彬
+2351101402034;Ouchn@19860710;张好民
+2351101402035;Ouchn@19950320;李文杰
+2351101402036;Ouchn@20000511;熊浚池
+2351101402037;Ouchn@20030905;张娅欣
+2351101402038;Ouchn@20021202;何佳
+2351101402039;Ouchn@19751203;曾宽树
+2351101402040;Ouchn@19881016;陈位艳
+2351101402041;Ouchn@19900617;郭梅
+2351101402042;Ouchn@19941027;郭菲
+2351101402043;Ouchn@19961103;陈菊
+2351101402044;Ouchn@19890307;喻芳
+2351101402045;Ouchn@19920616;冯漂
+2351101402046;Ouchn@19800829;周鑫
+2351101402047;Ouchn@19930329;冯凡
+2351101402048;Ouchn@20010221;许慧铭
+2351101402049;Ouchn@19990613;涂超红
+2351101402050;Ouchn@20030910;林心语
+2351101402051;Ouchn@19930625;瞿祯岑
+2351101402052;Ouchn@19811024;陈春彦
+2351101402053;Ouchn@19990720;徐小倩
+2351101402054;Ouchn@19880602;叶菊
+2351101402055;Ouchn@19901205;杨桂兰
+2351101402056;Ouchn@19850103;李金秀
+2351101402057;Ouchn@19921110;曹丹
+2351101402058;Ouchn@19940712;晋文涛
+2351101402059;Ouchn@19941123;贾正莹
+2351101402060;Ouchn@19840819;李泽菊
+2351101402061;Ouchn@19860920;唐建军
+2351101402062;Ouchn@19820922;黄昌珍
+2351101400471;Ouchn@19960219;陈邦松
+2351101400472;Ouchn@19980808;刘越
+2351101400489;Ouchn@19890522;周瑞

+ 3 - 3
common.yaml

@@ -1,14 +1,14 @@
 videoInterval: 10
 courses:
-- "习近平新时代中国特色社会主义思想概论"
+- "政治学原理"
 specialCourses:
-- "习近平新时代中国特色社会主义思想概论"
+- "政治学原理"
 channel: 1
 visitCount: 0
 NewStyle: false
 SleepTime: 60
 
-codeManual: true
+codeManual: false
 #target 1 视频和题目都处理 2 只拉视频 3 只刷题
 target: 1
 timeout: 20

+ 3 - 0
record.txt

@@ -1,2 +1,5 @@
 2251106450096 Ouchn@19850808 谢红
 2351101200900 Ouchn@19860427 文寅
+2351101400301 Ouchn@19960206 何清清
+2351101402032 Ouchn@19960428 奚伟杰
+2351101402033 Ouchn@19821216 陈彬

+ 21 - 11
student/student.go

@@ -130,7 +130,8 @@ func codeGet(data []byte, account string, token string) (bool, string) {
 	contentType := bodyWriter.FormDataContentType()
 	bodyWriter.Close()
 
-	resp, _ := http.Post("http://www.bhshare.cn/imgcode/", contentType, bodyBuffer)
+	resp, err := http.Post("http://www.bhshare.cn/imgcode/", contentType, bodyBuffer)
+	fmt.Println("验证码识别 err :", err)
 	defer resp.Body.Close()
 
 	resp_body, _ := ioutil.ReadAll(resp.Body)
@@ -1886,11 +1887,17 @@ func examHandleSubmit(wd selenium.WebDriver) error {
 
 func examHandle(wd selenium.WebDriver, courseId, moduleId, id string, qustionM map[string][]string, specialCourse bool) error {
 	cookie, _ := getCookies(wd)
-	if checkExamFinish(id, cookie) {
+	finsh, submited := checkExamFinish(id, cookie)
+	if finsh {
 		fmt.Printf("试题达到最大提交次数\n")
 		return nil
 	}
 
+	if submited {
+		fmt.Printf("已完成该试题\n")
+		return nil
+	}
+
 	// 跳转页面
 	if err := examHandleJump(wd, courseId, moduleId, id); err != nil {
 		return err
@@ -1951,11 +1958,11 @@ func examHandle(wd selenium.WebDriver, courseId, moduleId, id string, qustionM m
 	return err
 }
 
-func checkExamFinish(id string, cookie string) bool {
+func checkExamFinish(id string, cookie string) (finish bool, submited bool) {
 	url := fmt.Sprintf("https://lms.ouchn.cn/api/exams/%s", id)
 	request, err := http.NewRequest("GET", url, nil)
 	if err != nil {
-		return false
+		return false, false
 	}
 
 	request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
@@ -1966,21 +1973,24 @@ func checkExamFinish(id string, cookie string) bool {
 	client := http.Client{}
 	resp, err := client.Do(request)
 	if err != nil {
-		return false
+		return false, false
 	}
 	defer resp.Body.Close()
 
 	respBytes, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
-		return false
+		return false, false
 	}
 	submitTimes := gjson.GetBytes(respBytes, "submit_times").Int()
 	submittedTimes := gjson.GetBytes(respBytes, "submitted_times").Int()
+	if submittedTimes > 0 {
+		submited = true
+	}
 	if submitTimes == submittedTimes && submitTimes > 0 {
-		return true
+		return true, submited
 	}
 
-	return false
+	return false, submited
 
 }
 
@@ -2032,7 +2042,7 @@ func finishUploadId(uploadId int64, moduleId string, cookie string) error {
 func finishMaterial(uploadIds []int64, moduleId string, cookie string) {
 	for _, v := range uploadIds {
 		finishUploadId(v, moduleId, cookie)
-		time.Sleep(1 * time.Second)
+		time.Sleep(time.Duration(config.Conf.VideoInterval) * time.Second)
 	}
 }
 
@@ -2168,8 +2178,8 @@ func CourseHandle(wd selenium.WebDriver, username string) error {
 					if err != nil {
 						fmt.Printf("获取播放按钮失败\n")
 					}
-
-					return err
+					continue
+					//return err
 				}
 
 				playButton, _ := wd.FindElement(selenium.ByXPATH, "//button[@class='mvp-toggle-play mvp-first-btn-margin']")