1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.everyday.word.utils;
 
import org.yeshi.utils.FileUtil;
 
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
 
/**
 * @author hxh
 * @title: YouDaoWebUtil
 * @description: 有道网页工具
 * @date 2024/9/14 16:30
 */
public class YouDaoWebUtil {
    private final static String BASE_DIR = "D:\\项目\\单词\\词库\\有道网页资源";
 
    public static void saveBaseInfo(String spelling, String info) throws IOException {
        FileUtil.saveAsFileByte(info.getBytes("UTF-8") ,String.format("%s\\%s\\%s.json",BASE_DIR,"基本信息",spelling));
    }
 
    public static Set<String> getBaseInfoSpellings(){
        File f =new File(String.format("%s\\%s",BASE_DIR,"基本信息"));
        File[] fs=     f.listFiles();
        Set<String> spellings=new HashSet<>();
        for(File ff: fs){
            if(ff.length()>100){
                spellings.add(ff.getName().replace(".json",""));
            }
        }
        return spellings;
    }
 
    public static void saveLJ(String spelling, String info) throws IOException{
        FileUtil.saveAsFileByte(info.getBytes("UTF-8") ,String.format("%s\\%s\\%s.json",BASE_DIR,"例句",spelling));
    }
 
    public static Set<String> getLJSpellings(){
        File f =new File(String.format("%s\\%s",BASE_DIR,"例句"));
        File[] fs=     f.listFiles();
        Set<String> spellings=new HashSet<>();
        for(File ff: fs){
            if(ff.length()>100){
                spellings.add(ff.getName().replace(".json",""));
            }
        }
        return spellings;
    }
 
    public static void main(String[] args) throws IOException {
//        String spelling = "candlestick";
//        String info =  YouDaoWebApi.getInfoBySpelling(spelling);
//        saveBaseInfo(spelling, info);
//        info =  YouDaoWebApi.getLJBySpelling(spelling);
//        saveLJ(spelling, info);
 
        getBaseInfoSpellings();
        getLJSpellings();
    }
 
}