Open yooonmyong opened 5 years ago
@Autowired MapSearchContextImpl mapSearchContext; @Autowired OverallDao overallDao; @Test public void fillOverall() throws Exception { mapSearchContext.getStationFile("src/station.csv"); mapSearchContext.getStationList(); } @Autowired InstaCrawlImpl instaCrawl; @Autowired InstahotDao instahotDao; @Autowired FileDelete fileDelete; private WebDriver webDriver; private int index = 1; List<Instahot> instahots = new ArrayList<>(); List<String> p = new ArrayList<>(); @Test public void fillInstahot() throws Exception { String url = "https://www.instagram.com/explore/tags/" + "숙대입구역맛집"; String station = "숙대입구역"; webDriver = instaCrawl.setUpWebDriver(url, station); while (true) { if (index == 1) { instaCrawl.waitPage(webDriver, 1, 16); } else { if (instaCrawl.waitPage(webDriver, 2, 0) == 3) { //skipPosts는 초기에만 필요한 매개변수 break; } } Instahot instahot = new Instahot(); instahot.setStation(station); instahot.setPost(instaCrawl.getPost(webDriver)); instahot.setDate(instaCrawl.getDate(webDriver)); p.add(instaCrawl.getPhotopageURL(webDriver)); instahots.add(instahot); index++; if (index == 10) { break; } } index = 0; for (String pp : p) { System.out.println(index+1 + "번째-----------------------------------------------"); instahots.get(index).setPhotoURL(instaCrawl.getPhotoURL(webDriver, station, pp)); index++; } for (Instahot a : instahots) { instahotDao.save(a); } fileDelete.deleteFiles("/Users/kym/Spring-Pllabel", ".jpg"); } List<Instaplace> instaplaces = new ArrayList<>(); List<Instafood> instafoods = new ArrayList<>(); @Autowired InstaplaceDao instaplaceDao; @Autowired InstafoodDao instafoodDao; @Test public void fillInstafood() throws Exception { String url = "https://www.instagram.com/explore/tags/" + "숙대입구역맛집"; String station = "숙대입구역"; webDriver = instaCrawl.setUpWebDriver(url, station); while (true) { if (index == 1) { instaCrawl.waitPage(webDriver, 1, 9); } else { if (instaCrawl.waitPage(webDriver, 2, 0) == 3) { //skipPosts는 초기에만 필요한 매개변수 break; } } System.out.println("---------------------------------------------"); Instafood instaplace = new Instafood(); String a = instaCrawl.getPost(webDriver); instaplace.setStation("숙대입구역"); instaplace.setPost(a); instaplace.setLikeCNT(instaCrawl.getLikeCNT(webDriver)); instaplace.setDate(instaCrawl.getDate(webDriver)); instaplace.setMyRestaurant(new ArrayList<>()); p.add(instaCrawl.getPhotopageURL(webDriver)); instafoods.add(instaplace); index++; if (index == 6) { break; } } index = 0; for (String pp : p) { System.out.println(index+1 + "번째-----------------------------------------------"); instafoods.get(index).setPhotoURL(instaCrawl.getPhotoURL(webDriver, station, pp)); index++; } for (Instafood a : instafoods) { instafoodDao.save(a); } fileDelete.deleteFiles("/Users/kym/Spring-Pllabel", ".jpg"); } @Test public void fillInstaplace() throws Exception { String url = "https://www.instagram.com/explore/tags/" + "숙입"; String station = "숙대입구역"; webDriver = instaCrawl.setUpWebDriver(url, station); while (true) { if (index == 1) { instaCrawl.waitPage(webDriver, 1, 9); } else { if (instaCrawl.waitPage(webDriver, 2, 0) == 3) { //skipPosts는 초기에만 필요한 매개변수 break; } } System.out.println("---------------------------------------------"); Instaplace instaplace = new Instaplace(); String a = instaCrawl.getPost(webDriver); instaplace.setStation("숙대입구역"); instaplace.setPost(a); instaplace.setLikeCNT(instaCrawl.getLikeCNT(webDriver)); instaplace.setDate(instaCrawl.getDate(webDriver)); instaplace.setDescription(""); instaplace.setHashtag(instaCrawl.getHashtags(webDriver, a)); instaplaces.add(instaplace); index++; if (index == 6) { break; } } for (Instaplace a : instaplaces) { instaplaceDao.save(a); } } @Autowired YoutubeApiTrim youtubeApiTrim; @Autowired YoutubehotDao youtubehotDao; @Autowired YoutubefoodDao youtubefoodDao; @Test public void fillYoutubefood() { List<Object> a = youtubeApiTrim.SearchKeyword("숙대입구역 맛집", "숙대입구역", 1); for (Object aa : a) { Youtubefood k = (Youtubefood) aa; youtubefoodDao.save(k); } } @Test public void fillYoutubehot() { List<Object> a = youtubeApiTrim.SearchKeyword("숙대입구역", "숙대입구역", 2); for (Object aa : a) { Youtubehot k = (Youtubehot) aa; youtubehotDao.save(k); } }