Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 베스트 셀러 크롤링 기능 추가 #42

Merged
merged 4 commits into from
Mar 27, 2024

Conversation

jwooo
Copy link
Collaborator

@jwooo jwooo commented Mar 27, 2024

💡 연관된 이슈

close #34

📝 작업 내용

  • 베스트 셀러 BookId 크롤링 기능
  • BookId를 통한 도서 상세 정보 크롤링 기능

💬 리뷰 요구 사항

베스트 셀러 목록을 가져와서 처리하는 부분을 CompletableFuture를 사용하여 비동기 Blocking I/O로 처리하였습니다.

public Map<Long, CrawlingBook> crawlBestSellerBook() {
	Map<Long, String> bestSellerBookIds = parser.parseBestSellerBookId(fetcher.fetchBestSellerBookId());
	Map<Long, CrawlingBook> bestSellerBooks = new HashMap<>();
	
	List<CompletableFuture<Void>> futures = bestSellers.entrySet().stream().
			.map(entry -> CompletableFuture.supplyAsnc(() -> parser.parseBook(fetcher.fetchBook(entry.getValue())))
					.thenAccept(crawlingBook -> bestSellerBooks.put(entry.getKey(), crawlingBook)))
			.toList();
			
	CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join();
	
	return bestSellerBooks;
}

해당 내용에 관련된 글은 노션에 작성하겠습니다. 이에 대해 궁금하신 사항이나 잘못된 점 알려주시면 감사하겠습니다!

노션 링크

@jwooo jwooo added the ✨ Feature 기능 개발 label Mar 27, 2024
@jwooo jwooo requested review from pdohyung and AHNYUNKI March 27, 2024 07:48
@jwooo jwooo self-assigned this Mar 27, 2024
@jwooo jwooo linked an issue Mar 27, 2024 that may be closed by this pull request
2 tasks
Copy link
Member

@pdohyung pdohyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내용 확인 했습니다 ~
남긴 질문에 답변 남겨주세요 ! 😆

Comment on lines 12 to +21
@Component
@Setter
@ConfigurationProperties(prefix = "crawler.yes24.fetcher")
public class Yes24Fetcher implements Fetcher {

private String isbnUrl;
private String bookUrl;
private String bestBookUrl;
private String userAgent;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크롤링을 위한 설정값을 바인딩 하기 위해 @Setter를 쓰신 건가요 ??
다른 방법은 없을까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞습니다. @ConfigurationProperties는 yaml 파일에 있는 값을 동적으로 변경할 수 있습니다. 그렇기 때문에 생성된 빈에 대해서는 @Setter를 통해서 yaml 파일의 값을 가져야 설정할 수 있습니다.

다른 방법이라 하면 @Value를 통해서 값을 주입할 수 있지만 필드 하나마다 경로를 설정해야 하는 단점이 있지만 주입받는 필드를 final로 설정할 수 있다는 장점이 있습니다.

현재는 주입받는 필드가 많아 @ConfigurationProperties를 사용하였습니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 그렇군요 ! 감사합니다.

Copy link
Member

@pdohyung pdohyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다. 👍

Copy link
Member

@AHNYUNKI AHNYUNKI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오... 어려웠을텐데 잘 구현하셨군요!
수고하셨습니다 ! 정우님!

@jwooo jwooo merged commit 555e2c9 into develop Mar 27, 2024
1 check passed
@jwooo jwooo deleted the feature/34-crawling-best-book branch March 27, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] 베스트 셀러 크롤링 기능 추가
3 participants