File tree Expand file tree Collapse file tree
src/main/java/com/playhive/batch/crawler/news/esports Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ private void crawlForDate(LocalDate date) {
110110 LocalDateTime postDate = parseRelativeTime (postDateStr );
111111 String title = getTitle (news );
112112 String content = getContent (news );
113+ String thumb = extractImage (news );
114+
115+ if (thumb == null || thumb .isBlank ()) {
116+ log .debug ("🔍 썸네일 없음, 기본값 또는 상세 진입 고려: {}" , source );
117+ }
113118
114119 if (title .isBlank ()) {
115120 log .debug ("⛔ 무시됨 - 제목 없음: {}" , source );
@@ -184,6 +189,20 @@ private LocalDateTime parseRelativeTime(String timeStr) {
184189 }
185190 }
186191
192+ private String extractImage (WebElement news ) {
193+ try {
194+ WebElement thumbnailDiv = news .findElement (By .className ("news_card_thumbnail__3thTg" ));
195+ String style = thumbnailDiv .getAttribute ("style" ); // style="background-image: url(...)"
196+ Matcher matcher = Pattern .compile ("url\\ ([\" ']?(.*?)[\" ']?\\ )" ).matcher (style );
197+ if (matcher .find ()) {
198+ return matcher .group (1 );
199+ }
200+ } catch (NoSuchElementException e ) {
201+ log .debug ("❌ 썸네일 div 없음" );
202+ }
203+ return null ;
204+ }
205+
187206 private void save (List <NewsSaveRequest > newsList ) {
188207 for (NewsSaveRequest news : newsList ) {
189208 try {
You can’t perform that action at this time.
0 commit comments