瀏覽代碼

抓获取一点通 语音和图片

小么熊🐻 1 年之前
父節點
當前提交
f0b3696bd4

+ 145 - 10
zzjs-admin/src/test/java/com/miaxis/test/YdtTest.java

@@ -24,6 +24,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 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;
@@ -240,16 +241,6 @@ public class YdtTest {
 
     }
 
-    @Test
-    public void getVoice2() throws IOException {
-
-        WebNoteJs webNoteJs = new WebNoteJs();
-        webNoteJs.setId(1l);
-        webNoteJs.setQbAnalyse("12312");
-        webNoteJs.setQbReadAnalyse("12312");
-        webNoteJs.setQbSkillAudioLink("https");
-        webNoteJsService.save(webNoteJs);
-    }
 
     @Test
     public void getVoice() throws IOException {
@@ -390,7 +381,151 @@ public class YdtTest {
         System.out.println(lastName);
 
 
+    }
+
+
+    /**
+     * 抓取一点通解释
+     * @throws IOException
+     */
+    @Test
+    public void getWebNoteJs() throws IOException {
+        List<WebNoteAll> list = webNoteAllService.selectWebNoteAllList(null);
+
+        for (int i = 0; i < list.size(); i++) {
+            WebNoteAll webNoteAll = list.get(i);
+            WebNoteJs webNoteJs = this.getWebNoteJsById(webNoteAll.getId());
+            webNoteJsService.save(webNoteJs);
+        }
+    }
+
+
+
+    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+"\"}";
+            byte[] requestBodyBytes = data.getBytes(StandardCharsets.UTF_8);
+
+            // 创建URL对象
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            // 设置请求方法
+            con.setRequestMethod("POST");
+
+            // 添加请求头
+            con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // 添加您提供的Cookie数据
+            con.setRequestProperty("Cookie", "cityid=150; hpincode=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJjbGllbnRJcFwiOlwiMTEyLjExMS4xMy4yM1wiLFwiZGV2aWNlSWRcIjpcIjIxZjQ3OWJhYjA5OTRiOWI5MTMxNDYzOTY3MzE0ZjRjXCIsXCJpbWVpXCI6XCI4MDgyZDgzMTQ5ZjRkM2FmZmFjNDE2MWUyZGNhODhjNjVkNWU3YmVmXCIsXCJqeElkXCI6MCxcImxvZ2luVGltZVwiOjE2OTE1NzM3OTQ3OTYsXCJ1c2VyaWRcIjozNjMyNjI3MDYyMjg4MTU0NjkwfSIsImlzcyI6IkpYRURUIiwiZXhwIjoxNzIyNjc3Nzk0LCJpYXQiOjE2OTE1NzM3OTN9.bJkc5cr1yg1eBQfYacp44vopZ2kdPL6jza145HMcA33GY0G4TxKBhILPzG1BdbtvI_eEkj4dz2dOKl1m3xKFBg; userid=3632627062288154690; cversion=\"12.9.1\"; id58=CrIjjmTVmW8plvruH8ODAg==");
+            con.setRequestProperty("learnstage", "10");
+            con.setRequestProperty("hsign", "7bc6ba8d55801ed75f2b7302526aaca3");
+            con.setRequestProperty("hos", "ios");
+            con.setRequestProperty("kemutype", "1");
+            con.setRequestProperty("happver", "12.9.1");
+            con.setRequestProperty("htime", "1691750773121");
+            con.setRequestProperty("channelid", "80000");
+            con.setRequestProperty("cartype", "0");
+            con.setRequestProperty("hurl", "https://kaoshiapi.ksedt.com/sns/exam/getQuestionInfo");
+            con.setRequestProperty("hsnssign", "8c21a00420324734a631afdbeb8b63e8");
+            con.setRequestProperty("hpath", "https://kaoshiapi.ksedt.com/sns/exam/getQuestionInfo");
+            con.setRequestProperty("version", "12.9.1");
+            con.setRequestProperty("hpincode", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJjbGllbnRJcFwiOlwiMTEyLjExMS4xMy4yM1wiLFwiZGV2aWNlSWRcIjpcIjIxZjQ3OWJhYjA5OTRiOWI5MTMxNDYzOTY3MzE0ZjRjXCIsXCJpbWVpXCI6XCI4MDgyZDgzMTQ5ZjRkM2FmZmFjNDE2MWUyZGNhODhjNjVkNWU3YmVmXCIsXCJqeElkXCI6MCxcImxvZ2luVGltZVwiOjE2OTE1NzM3OTQ3OTYsXCJ1c2VyaWRcIjozNjMyNjI3MDYyMjg4MTU0NjkwfSIsImlzcyI6IkpYRURUIiwiZXhwIjoxNzIyNjc3Nzk0LCJpYXQiOjE2OTE1NzM3OTN9.bJkc5cr1yg1eBQfYacp44vopZ2kdPL6jza145HMcA33GY0G4TxKBhILPzG1BdbtvI_eEkj4dz2dOKl1m3xKFBg");
+            con.setRequestProperty("packagename", "com.jiaxiao");
+            con.setRequestProperty("hsimplytourist", "false");
+            con.setRequestProperty("hproductid", "3");
+            con.setRequestProperty("productid", "3");
+            con.setRequestProperty("happid", "201826471087328101");
+            con.setRequestProperty("hsignsuffix", "hZLJ3qzMgFK25A2S");
+            con.setRequestProperty("hr", "475167");
+            con.setRequestProperty("hext-union", "sFCm__rrLh3S5ejYBvO13dP8L3ExHXf9cjA2DHI2gXcMLWUBSK7ITmcykahNuawIuUDqoyvcKR46YyezxvynMJzBa72wXnhB-2y0RjoZ-2S4oUgdahCc0vY4MDXvV8Jcu1oAOR5xEunsJlYjudIjlojrUk1VDi8CfkDVjZXPHhEQAzTcnD0P7tRubI8SejBTmONewlScIkaAmMkKpztdaP7wR8K1EARfmF0e3xLttfI");
+
+
+
+            // 启用输出流,以便可以发送请求体
+            con.setDoOutput(true);
+
+            // 构建请求体并写入输出流
+            try (OutputStream os = con.getOutputStream()) {
+                byte[] input = data.getBytes("utf-8");
+                os.write(input, 0, input.length);
+            }
+
+            // 获取响应
+            int responseCode = con.getResponseCode();
+            System.out.println("Response Code: " + responseCode);
+
+            // 读取响应内容
+            try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
+                String inputLine;
+                StringBuilder response = new StringBuilder();
 
+                while ((inputLine = in.readLine()) != null) {
+                    response.append(inputLine);
+                }
+
+                // 打印响应内容
+                System.out.println("Response Content:\n" + response.toString());
+
+                JSONObject jsonObject = JSONObject.parseObject(response.toString());
+
+                JSONObject result = jsonObject.getJSONObject("result");
+                JSONObject skillEntity = result.getJSONObject("skillEntity");
+                String qbAnalyse = skillEntity.getString("qbAnalyse");
+                String qbReadAnalyse = skillEntity.getString("qbReadAnalyse");
+                String qbSkillAudioLink = skillEntity.getString("qbSkillAudioLink");
+
+                JSONObject specialInfo = result.getJSONObject("specialInfo");
+                String firTitle = specialInfo.getString("firTitle");
+                String secTitle = specialInfo.getString("secTitle");
+                String word = specialInfo.getString("word");
+
+
+                WebNoteJs webNoteJs = new WebNoteJs();
+                webNoteJs.setId(id);
+                webNoteJs.setQbAnalyse(qbAnalyse);
+                webNoteJs.setQbReadAnalyse(qbReadAnalyse);
+                webNoteJs.setQbSkillAudioLink(qbSkillAudioLink);
+                webNoteJs.setFirTilte(firTitle);
+                webNoteJs.setSecTitle(secTitle);
+                webNoteJs.setWord(word);
+
+                return webNoteJs;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+
+    @Test
+    public void getJsVoice()  {
+
+        try {
+
+            List<WebNoteJs> list = webNoteJsService.selectWebNoteJsList(null);
+            System.out.println(list.size());
+            for (int i = 9287; i < list.size(); i++) {
+                WebNoteJs webNoteJs = list.get(i);
+                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);
+                    System.out.println(lastName);
+                    System.out.println(fileName);
+                    System.out.println(fileName+lastName);
+                    String allName = fileName+lastName;
+                    downLoadFromUrl(webNoteJs.getQbSkillAudioLink(),allName,savePath);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
 }

+ 42 - 0
zzjs-service/src/main/java/com/miaxis/question/domain/WebNoteJs.java

@@ -47,6 +47,24 @@ public class WebNoteJs extends BaseBusinessEntity{
     @ApiModelProperty(value = "技巧你语音链接")
     private String qbSkillAudioLink;
 
+    /** 总结主标题 */
+    @Excel(name = "总结主标题")
+    @TableField("fir_tilte")
+    @ApiModelProperty(value = "总结主标题")
+    private String firTilte;
+
+    /** 总结子村题 */
+    @Excel(name = "总结子村题")
+    @TableField("sec_title")
+    @ApiModelProperty(value = "总结子村题")
+    private String secTitle;
+
+    /** 总结内容每一点用“;”隔开 */
+    @Excel(name = "总结内容每一点用“;”隔开")
+    @TableField("word")
+    @ApiModelProperty(value = "总结内容每一点用“;”隔开")
+    private String word;
+
     public void setId(Long id){
         this.id = id;
     }
@@ -75,6 +93,27 @@ public class WebNoteJs extends BaseBusinessEntity{
     public String getQbSkillAudioLink(){
         return qbSkillAudioLink;
     }
+    public void setFirTilte(String firTilte){
+        this.firTilte = firTilte;
+    }
+
+    public String getFirTilte(){
+        return firTilte;
+    }
+    public void setSecTitle(String secTitle){
+        this.secTitle = secTitle;
+    }
+
+    public String getSecTitle(){
+        return secTitle;
+    }
+    public void setWord(String word){
+        this.word = word;
+    }
+
+    public String getWord(){
+        return word;
+    }
 
     @Override
     public String toString() {
@@ -83,6 +122,9 @@ public class WebNoteJs extends BaseBusinessEntity{
             .append("qbAnalyse", getQbAnalyse())
             .append("qbReadAnalyse", getQbReadAnalyse())
             .append("qbSkillAudioLink", getQbSkillAudioLink())
+            .append("firTilte", getFirTilte())
+            .append("secTitle", getSecTitle())
+            .append("word", getWord())
             .append("createTime", getCreateTime())
             .append("updateTime", getUpdateTime())
             .toString();

+ 6 - 0
zzjs-service/src/main/resources/mapper/question/WebNoteJsMapper.xml

@@ -9,6 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="qbAnalyse"    column="qb_analyse"    />
         <result property="qbReadAnalyse"    column="qb_read_analyse"    />
         <result property="qbSkillAudioLink"    column="qb_skill_audio_link"    />
+        <result property="firTilte"    column="fir_tilte"    />
+        <result property="secTitle"    column="sec_title"    />
+        <result property="word"    column="word"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
     </resultMap>
@@ -23,6 +26,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="qbAnalyse != null  and qbAnalyse != ''"> and qb_analyse = #{qbAnalyse}</if>
             <if test="qbReadAnalyse != null  and qbReadAnalyse != ''"> and qb_read_analyse = #{qbReadAnalyse}</if>
             <if test="qbSkillAudioLink != null  and qbSkillAudioLink != ''"> and qb_skill_audio_link = #{qbSkillAudioLink}</if>
+            <if test="firTilte != null  and firTilte != ''"> and fir_tilte = #{firTilte}</if>
+            <if test="secTitle != null  and secTitle != ''"> and sec_title = #{secTitle}</if>
+            <if test="word != null  and word != ''"> and word = #{word}</if>
         </where>
     </select>