|
@@ -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']")
|