|
@@ -5,7 +5,9 @@ import java.io.IOException;
|
|
|
import java.sql.SQLException;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import com.mingxue.spider.helper.Convert;
|
|
|
import com.mingxue.spider.helper.StringUtils;
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -47,7 +49,7 @@ public class CollegeData {
|
|
|
//181
|
|
|
public void collegeList() throws SQLException {
|
|
|
// int count = 0, total = 5000, page = 131;
|
|
|
- int count = 0, total = 5000, page = 14;
|
|
|
+ int count = 0, total = 5000, page = 1;
|
|
|
JSONObject res=new JSONObject();
|
|
|
do {
|
|
|
try {
|
|
@@ -86,7 +88,7 @@ public class CollegeData {
|
|
|
/**
|
|
|
* 院校录取数据
|
|
|
*/
|
|
|
- List<Integer> liberalScienceList= Arrays.asList(1,2);
|
|
|
+ List<Integer> liberalScienceList= Arrays.asList(0,1);
|
|
|
List<Integer> typeList= Arrays.asList(2,3);
|
|
|
for(Integer liberalScience:liberalScienceList){
|
|
|
for(Integer type:typeList){
|
|
@@ -112,6 +114,26 @@ public class CollegeData {
|
|
|
System.out.println("执行完成!");
|
|
|
}
|
|
|
|
|
|
+ //字体编码
|
|
|
+ static Map<Integer,String> fontMap = new HashMap<Integer, String>(){{
|
|
|
+ put(1, "0923546781");
|
|
|
+ put(2, "0329547681");
|
|
|
+ put(3, "0359247681");
|
|
|
+ put(4, "0351426789");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ private static String getRealData(Integer fontId, String data){
|
|
|
+ if(StringUtils.isBlank(data)){
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ StringBuilder result = new StringBuilder();
|
|
|
+ for(char index:data.toCharArray()){
|
|
|
+ result.append(fontMap.get(fontId).toCharArray()[Integer.parseInt(String.valueOf(index))]);
|
|
|
+ }
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* 院校录取数据
|
|
|
* Request URL: https://apiv4.diyigaokao.com/query/collegeScore/byHistoryNew?liberalScience=1&collegeId=1&type=2
|
|
@@ -135,11 +157,39 @@ public class CollegeData {
|
|
|
//data
|
|
|
JSONObject dataObject = res.getJSONObject("data");
|
|
|
JSONArray tdDatas = dataObject.getJSONArray("tdData");
|
|
|
+ JSONArray thDatasArray = dataObject.getJSONArray("thData");
|
|
|
+// Map<String,String> thDatasMap = new HashMap<>();
|
|
|
+// thDatasArray.forEach(m->{
|
|
|
+// JSONObject thDatasJSONObject = (JSONObject) m;
|
|
|
+// if(thDatasJSONObject.getInteger("encryption")==1){
|
|
|
+// thDatasMap.put(thDatasJSONObject.getString("prop"),thDatasJSONObject.getString("prop"));
|
|
|
+// }
|
|
|
+// });
|
|
|
+ //font
|
|
|
+ JSONObject font = res.getJSONObject("font");
|
|
|
+ Integer fontId = font.getInteger("id");
|
|
|
+ String fontValue = fontMap.get(fontId);
|
|
|
+
|
|
|
Set<Entity> subjectList=new HashSet();
|
|
|
for (int i = 0; i < tdDatas.size(); i++) {
|
|
|
//sy_colledge_enroll_data
|
|
|
JSONObject row = tdDatas.getJSONObject(i);
|
|
|
row.put("type",type);
|
|
|
+ row.put("font_id",fontId);
|
|
|
+ row.put("font_value",fontValue);
|
|
|
+ //解密错位数据
|
|
|
+ thDatasArray.forEach(m->{
|
|
|
+ JSONObject thDatasJSONObject = (JSONObject) m;
|
|
|
+ if(thDatasJSONObject.getInteger("encryption")==1){
|
|
|
+ String prop = thDatasJSONObject.getString("prop");
|
|
|
+ String originalValue = row.getString(prop);
|
|
|
+ if(StringUtils.isNotBlank(originalValue)){
|
|
|
+ String realValue=getRealData(fontId,originalValue);
|
|
|
+ row.put(prop,realValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
Entity subjectTable4 = Entity.create("sy_colledge_enroll_data");
|
|
|
subjectTable4.putAll(row);
|
|
|
subjectList.add(subjectTable4);
|
|
@@ -384,4 +434,9 @@ public class CollegeData {
|
|
|
System.out.println("finished");
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+// public static void main(String[] args) {
|
|
|
+// System.out.println(getRealData(1,"694"));
|
|
|
+// System.out.println(getRealData(1,"698"));
|
|
|
+// }
|
|
|
}
|