-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: html 크롤링 방식과 naver api 방식을 조합하는 Extractor 구현
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...d/src/main/java/com/zzang/chongdae/offering/service/CombinationProductImageExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.zzang.chongdae.offering.service; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class CombinationProductImageExtractor implements ProductImageExtractor { | ||
|
||
private final List<ProductImageExtractor> extractors; | ||
|
||
@Override | ||
public String extract(String productUrl) { | ||
for (ProductImageExtractor extractor : extractors) { | ||
String imageUrl = extractor.extract(productUrl); | ||
if (isExtractSuccess(imageUrl)) { | ||
return imageUrl; | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
private boolean isExtractSuccess(String imageUrl) { | ||
return !imageUrl.isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters