|
@@ -14,7 +14,6 @@ import com.miaxis.question.service.IQuestionInfoGetService;
|
|
|
import com.miaxis.question.service.IQuestionYdtJsService;
|
|
|
import com.miaxis.question.service.IWebNoteAllService;
|
|
|
import com.miaxis.question.service.IWebNoteJsService;
|
|
|
-import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -25,9 +24,7 @@ import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@SpringBootTest(classes = ZzjsApplication.class)
|
|
|
@RunWith(SpringRunner.class)
|
|
@@ -51,7 +48,6 @@ public class YdtTest {
|
|
|
private IWebNoteJsService webNoteJsService;
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取一点通题库
|
|
|
*/
|
|
@@ -114,6 +110,7 @@ public class YdtTest {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Test
|
|
|
public void getSkillInfo2() {
|
|
|
Ydt ydt = new Ydt();
|
|
@@ -133,7 +130,7 @@ public class YdtTest {
|
|
|
ydt.setQuestionId(String.valueOf(24));
|
|
|
String jsonObject = JSONObject.toJSONString(ydt);
|
|
|
System.out.println(jsonObject);
|
|
|
- // String data= "{\"nonceStr\":\"DA84C605-A06E-4EC6-BC78-0E935E77A80C\",\"questionId\":\"24\"}";
|
|
|
+ // String data= "{\"nonceStr\":\"DA84C605-A06E-4EC6-BC78-0E935E77A80C\",\"questionId\":\"24\"}";
|
|
|
|
|
|
|
|
|
String result = ydtService.getQuestionInfo(jsonObject);
|
|
@@ -149,12 +146,11 @@ public class YdtTest {
|
|
|
// Include other header values...
|
|
|
String data = "data=%7B%22nonceStr%22%3A%22DA84C605-A06E-4EC6-BC78-0E935E77A80C%22%2C%22questionId%22%3A%2224%22%7D";
|
|
|
|
|
|
- // String response = ydtService.getQuestionInfo(cookie, hsign, userAgent, /*other headers...*/ data);
|
|
|
- // System.out.println(response);
|
|
|
+ // String response = ydtService.getQuestionInfo(cookie, hsign, userAgent, /*other headers...*/ data);
|
|
|
+ // System.out.println(response);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Test
|
|
|
public void getSkillInfo() {
|
|
|
|
|
@@ -219,11 +215,8 @@ public class YdtTest {
|
|
|
questionYdtJs.setYdtVideoSize(ydtVideoSize);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
String answers = "";
|
|
|
- if(qbAnswers!=null) {
|
|
|
+ if (qbAnswers != null) {
|
|
|
for (int j = 0; j < qbAnswers.size(); j++) {
|
|
|
String answer = qbAnswers.getString(j);
|
|
|
if (j == 0) {
|
|
@@ -243,54 +236,87 @@ public class YdtTest {
|
|
|
|
|
|
|
|
|
@Test
|
|
|
- public void getVoice() throws IOException {
|
|
|
+ public void getVoice() throws IOException, InterruptedException {
|
|
|
|
|
|
List<WebNoteAll> list = webNoteAllService.selectWebNoteAllList(null);
|
|
|
System.out.println(list.size());
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
WebNoteAll webNoteAll = list.get(i);
|
|
|
- if(!StringUtils.isEmpty(webNoteAll.getMediaUrl())) {
|
|
|
- String savePath = "G:\\中正\\题库\\20230809\\media";
|
|
|
+ if (!StringUtils.isEmpty(webNoteAll.getMediaUrl())) {
|
|
|
+ String savePath = "G:\\中正\\题库\\20230920\\media";
|
|
|
int index = webNoteAll.getMediaUrl().lastIndexOf("/");
|
|
|
int index2 = webNoteAll.getMediaUrl().lastIndexOf(".");
|
|
|
String lastName = webNoteAll.getMediaUrl().substring(index2);
|
|
|
- String fileName = webNoteAll.getMediaUrl().substring(index+1,index2);
|
|
|
+ String fileName = webNoteAll.getMediaUrl().substring(index + 1, index2);
|
|
|
System.out.println(lastName);
|
|
|
System.out.println(fileName);
|
|
|
- System.out.println(fileName+lastName);
|
|
|
- String allName = fileName+lastName;
|
|
|
- downLoadFromUrl(webNoteAll.getMediaUrl(),allName,savePath);
|
|
|
+ System.out.println(fileName + lastName);
|
|
|
+ String allName = fileName + lastName;
|
|
|
+ Thread.sleep(100);
|
|
|
+ downLoadFromUrl(webNoteAll.getMediaUrl(), allName, savePath);
|
|
|
}
|
|
|
-
|
|
|
- if(!StringUtils.isEmpty(webNoteAll.getQuestionAudio())) {
|
|
|
- String savePath = "G:\\中正\\题库\\20230809\\question_audio";
|
|
|
+ /*
|
|
|
+ if (!StringUtils.isEmpty(webNoteAll.getQuestionAudio())) {
|
|
|
+ String savePath = "G:\\中正\\题库\\20230920\\question_audio";
|
|
|
int index = webNoteAll.getQuestionAudio().lastIndexOf("/");
|
|
|
int index2 = webNoteAll.getQuestionAudio().lastIndexOf(".");
|
|
|
String lastName = webNoteAll.getQuestionAudio().substring(index2);
|
|
|
- String fileName = webNoteAll.getQuestionAudio().substring(index+1,index2);
|
|
|
+ String fileName = webNoteAll.getQuestionAudio().substring(index + 1, index2);
|
|
|
System.out.println(lastName);
|
|
|
System.out.println(fileName);
|
|
|
- System.out.println(fileName+lastName);
|
|
|
- String allName = fileName+lastName;
|
|
|
- downLoadFromUrl(webNoteAll.getQuestionAudio(),allName,savePath);
|
|
|
+ System.out.println(fileName + lastName);
|
|
|
+ String allName = fileName + lastName;
|
|
|
+ Thread.sleep(100);
|
|
|
+ downLoadFromUrl(webNoteAll.getQuestionAudio(), allName, savePath);
|
|
|
}
|
|
|
|
|
|
- if(!StringUtils.isEmpty(webNoteAll.getAnswerAudio())) {
|
|
|
- String savePath = "G:\\中正\\题库\\20230809\\answer_audio";
|
|
|
+ if (!StringUtils.isEmpty(webNoteAll.getAnswerAudio())) {
|
|
|
+ String savePath = "G:\\中正\\题库\\20230920\\answer_audio";
|
|
|
int index = webNoteAll.getAnswerAudio().lastIndexOf("/");
|
|
|
int index2 = webNoteAll.getAnswerAudio().lastIndexOf(".");
|
|
|
String lastName = webNoteAll.getAnswerAudio().substring(index2);
|
|
|
- String fileName = webNoteAll.getAnswerAudio().substring(index+1,index2);
|
|
|
+ String fileName = webNoteAll.getAnswerAudio().substring(index + 1, index2);
|
|
|
System.out.println(lastName);
|
|
|
System.out.println(fileName);
|
|
|
- System.out.println(fileName+lastName);
|
|
|
- String allName = fileName+lastName;
|
|
|
- downLoadFromUrl(webNoteAll.getAnswerAudio(),allName,savePath);
|
|
|
+ System.out.println(fileName + lastName);
|
|
|
+ String allName = fileName + lastName;
|
|
|
+ Thread.sleep(100);
|
|
|
+ downLoadFromUrl(webNoteAll.getAnswerAudio(), allName, savePath);
|
|
|
}
|
|
|
+ */
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void getVoice2() throws IOException, InterruptedException {
|
|
|
|
|
|
+ List<WebNoteJs> list = webNoteJsService.selectWebNoteJsList(null);
|
|
|
+ System.out.println(list.size());
|
|
|
+ for (int i = 8110; i < list.size(); i++) {
|
|
|
+ WebNoteJs webNoteJs = list.get(i);
|
|
|
+ if (!StringUtils.isEmpty(webNoteJs.getQbSkillAudioLink())) {
|
|
|
+ String savePath = "G:\\中正\\题库\\20230920\\skill_audio";
|
|
|
+ int index = webNoteJs.getQbSkillAudioLink().lastIndexOf("/");
|
|
|
+ int index2 = webNoteJs.getQbSkillAudioLink().lastIndexOf(".");
|
|
|
+ String lastName = webNoteJs.getQbSkillAudioLink().substring(index2);
|
|
|
+ String fileName = webNoteJs.getQbSkillAudioLink().substring(index + 1, index2);
|
|
|
+ System.out.println(lastName);
|
|
|
+ System.out.println(fileName);
|
|
|
+ System.out.println(fileName + lastName);
|
|
|
+ String allName = fileName + lastName;
|
|
|
+ Thread.sleep(100);
|
|
|
+ System.out.println("number:" + i);
|
|
|
+ try {
|
|
|
+ downLoadFromUrl(webNoteJs.getQbSkillAudioLink(), allName, savePath);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Test
|
|
|
public void getShortVideo() throws IOException {
|
|
|
String savePath = "G:\\中正\\一点通\\题库短视频";
|
|
@@ -299,12 +325,12 @@ public class YdtTest {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
QuestionYdtJs questionYdtJs = list.get(i);
|
|
|
Long id = questionYdtJs.getId();
|
|
|
- String shortUrl= questionYdtJs.getShortVideoUrl();
|
|
|
+ String shortUrl = questionYdtJs.getShortVideoUrl();
|
|
|
int index2 = shortUrl.lastIndexOf(".");
|
|
|
String lastName = shortUrl.substring(index2);
|
|
|
- String fileName = id+lastName;
|
|
|
+ String fileName = id + lastName;
|
|
|
System.out.println(fileName);
|
|
|
- downLoadFromUrl(shortUrl,fileName,savePath);
|
|
|
+ downLoadFromUrl(shortUrl, fileName, savePath);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -386,6 +412,7 @@ public class YdtTest {
|
|
|
|
|
|
/**
|
|
|
* 抓取一点通解释
|
|
|
+ *
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@Test
|
|
@@ -396,17 +423,22 @@ public class YdtTest {
|
|
|
WebNoteAll webNoteAll = list.get(i);
|
|
|
WebNoteJs webNoteJs = this.getWebNoteJsById(webNoteAll.getId());
|
|
|
webNoteJsService.save(webNoteJs);
|
|
|
+
|
|
|
+ webNoteAll.setExplain(webNoteJs.getBestExplainNew());
|
|
|
+ webNoteAll.setBestExplainNew(webNoteJs.getBestExplainNew());
|
|
|
+ webNoteAllService.updateById(webNoteAll);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- public WebNoteJs getWebNoteJsById(Long id){
|
|
|
+ public WebNoteJs getWebNoteJsById(Long id) {
|
|
|
|
|
|
try {
|
|
|
// URL和请求体数据
|
|
|
String url = "https://kaoshiapi.ksedt.com/sns/exam/getQuestionInfo";
|
|
|
- String data = "data={\"nonceStr\":\"DA84C605-A06E-4EC6-BC78-0E935E77A80C\",\"questionId\":\""+id+"\"}";
|
|
|
+ String data = "data={\"nonceStr\":\"DA84C605-A06E-4EC6-BC78-0E935E77A80C\",\"questionId\":\"" + id + "\"}";
|
|
|
byte[] requestBodyBytes = data.getBytes(StandardCharsets.UTF_8);
|
|
|
|
|
|
// 创建URL对象
|
|
@@ -442,7 +474,6 @@ public class YdtTest {
|
|
|
con.setRequestProperty("hext-union", "sFCm__rrLh3S5ejYBvO13dP8L3ExHXf9cjA2DHI2gXcMLWUBSK7ITmcykahNuawIuUDqoyvcKR46YyezxvynMJzBa72wXnhB-2y0RjoZ-2S4oUgdahCc0vY4MDXvV8Jcu1oAOR5xEunsJlYjudIjlojrUk1VDi8CfkDVjZXPHhEQAzTcnD0P7tRubI8SejBTmONewlScIkaAmMkKpztdaP7wR8K1EARfmF0e3xLttfI");
|
|
|
|
|
|
|
|
|
-
|
|
|
// 启用输出流,以便可以发送请求体
|
|
|
con.setDoOutput(true);
|
|
|
|
|
@@ -480,6 +511,8 @@ public class YdtTest {
|
|
|
String ydtVideoPic = skillEntity.getString("ydtVideoPic");
|
|
|
String ydtVideo = skillEntity.getString("ydtVideo");
|
|
|
|
|
|
+ String bestExplainNew = skillEntity.getString("bestExplainNew");
|
|
|
+
|
|
|
|
|
|
JSONObject specialInfo = result.getJSONObject("specialInfo");
|
|
|
String firTitle = specialInfo.getString("firTitle");
|
|
@@ -501,6 +534,8 @@ public class YdtTest {
|
|
|
|
|
|
|
|
|
webNoteJs.setWord(word);
|
|
|
+ webNoteJs.setBestExplainNew(bestExplainNew);
|
|
|
+
|
|
|
|
|
|
return webNoteJs;
|
|
|
}
|
|
@@ -511,9 +546,8 @@ public class YdtTest {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Test
|
|
|
- public void getJsVoice() {
|
|
|
+ public void getJsVoice() {
|
|
|
|
|
|
try {
|
|
|
|
|
@@ -521,17 +555,17 @@ public class YdtTest {
|
|
|
System.out.println(list.size());
|
|
|
for (int i = 9287; i < list.size(); i++) {
|
|
|
WebNoteJs webNoteJs = list.get(i);
|
|
|
- if(!StringUtils.isEmpty(webNoteJs.getQbSkillAudioLink())) {
|
|
|
+ if (!StringUtils.isEmpty(webNoteJs.getQbSkillAudioLink())) {
|
|
|
String savePath = "G:\\中正\\题库\\20230809\\skill_audio";
|
|
|
int index = webNoteJs.getQbSkillAudioLink().lastIndexOf("/");
|
|
|
int index2 = webNoteJs.getQbSkillAudioLink().lastIndexOf(".");
|
|
|
String lastName = webNoteJs.getQbSkillAudioLink().substring(index2);
|
|
|
- String fileName = webNoteJs.getQbSkillAudioLink().substring(index+1,index2);
|
|
|
+ String fileName = webNoteJs.getQbSkillAudioLink().substring(index + 1, index2);
|
|
|
System.out.println(lastName);
|
|
|
System.out.println(fileName);
|
|
|
- System.out.println(fileName+lastName);
|
|
|
- String allName = fileName+lastName;
|
|
|
- downLoadFromUrl(webNoteJs.getQbSkillAudioLink(),allName,savePath);
|
|
|
+ System.out.println(fileName + lastName);
|
|
|
+ String allName = fileName + lastName;
|
|
|
+ downLoadFromUrl(webNoteJs.getQbSkillAudioLink(), allName, savePath);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|