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();
|
}
|
|
}
|