From 8cc47cfe4c6d6b48e62cf00f6cbd0951ec57c264 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 11 二月 2025 17:00:53 +0800 Subject: [PATCH] 整体系统结构完善 --- src/test/java/com/everyday/word/WordsTest.java | 82 ++++++++++++++++++++-------------------- 1 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/everyday/word/WordsTest.java b/src/test/java/com/everyday/word/WordsTest.java index 74a0b34..c19a104 100644 --- a/src/test/java/com/everyday/word/WordsTest.java +++ b/src/test/java/com/everyday/word/WordsTest.java @@ -72,55 +72,55 @@ @Test public void pullDataFromYouDaoWeb() throws InterruptedException { - EnglishWordsMapper.DaoQuery daoQuery=new EnglishWordsMapper.DaoQuery(); - int page=5; - int pageSize = 100; - List<EnglishWords> list = englishWordsService.list(daoQuery,page, pageSize); - Set<String> oSpellings=new HashSet<>(); - for(EnglishWords e:list){ - oSpellings.add(e.getSpelling()); - } - Set<String> spellings=new HashSet<>(); - spellings.addAll(oSpellings); - - - - Set<String> infoSellings = YouDaoWebUtil.getBaseInfoSpellings(); - spellings.removeAll(infoSellings); - for(String s:spellings){ - try { - String result = YouDaoWebApi.getInfoBySpelling(s); - if (!StringUtil.isNullOrEmpty(result) && result.length() > 100) { - YouDaoWebUtil.saveBaseInfo(s,result); - } - }catch(Exception e){ - e.printStackTrace(); - break; + EnglishWordsMapper.DaoQuery daoQuery = new EnglishWordsMapper.DaoQuery(); + for (int page = 200; page < 300; page++) { + int pageSize = 100; + List<EnglishWords> list = englishWordsService.list(daoQuery, page, pageSize); + Set<String> oSpellings = new HashSet<>(); + for (EnglishWords e : list) { + oSpellings.add(e.getSpelling()); } - Thread.sleep(1000 + (int) (Math.random()*1000)); - } + Set<String> spellings = new HashSet<>(); + spellings.addAll(oSpellings); - Set<String> ljSellings = YouDaoWebUtil.getLJSpellings(); - spellings=new HashSet<>(); - spellings.addAll(oSpellings); - spellings.removeAll(ljSellings); - for(String s:spellings){ - try { - String result = YouDaoWebApi.getLJBySpelling(s); - if (!StringUtil.isNullOrEmpty(result) && result.length() > 100) { - YouDaoWebUtil.saveLJ(s,result); + Set<String> infoSellings = YouDaoWebUtil.getBaseInfoSpellings(); + spellings.removeAll(infoSellings); + for (String s : spellings) { + try { + String result = YouDaoWebApi.getInfoBySpelling(s); + if (!StringUtil.isNullOrEmpty(result) && result.length() > 100) { + System.out.println("info:"+s); + YouDaoWebUtil.saveBaseInfo(s, result); + } + } catch (Exception e) { + e.printStackTrace(); + break; } - }catch(Exception e){ - e.printStackTrace(); - break; + Thread.sleep(1000 + (int) (Math.random() * 1000)); } - Thread.sleep(1000 + (int) (Math.random()*1000)); + Set<String> ljSellings = YouDaoWebUtil.getLJSpellings(); + spellings = new HashSet<>(); + spellings.addAll(oSpellings); + spellings.removeAll(ljSellings); + for (String s : spellings) { + try { + String result = YouDaoWebApi.getLJBySpelling(s); + if (!StringUtil.isNullOrEmpty(result) && result.length() > 100) { + System.out.println("lj:"+s); + YouDaoWebUtil.saveLJ(s, result); + } + } catch (Exception e) { + e.printStackTrace(); + break; + } + + Thread.sleep(1000 + (int) (Math.random() * 1000)); + + } } - - } -- Gitblit v1.8.0