feat: 뽐뿌 인기 게시물 감지 로직 추가

- tr.baseList 선택으로 변경하여 인기 게시물 감지
- hotpop_bg_color 클래스로 인기 여부 판단
- HotDeal 생성 시 isPopular 값 설정

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
sanjeok77
2026-03-11 21:37:14 +09:00
parent 674b696421
commit fd58995802

View File

@@ -51,48 +51,57 @@ class PpomppuScraper(client: OkHttpClient) : BaseScraper(client) {
val deals = mutableListOf<HotDeal>()
// 셀렉터로 요소 찾기
val elements: Elements = doc.select("a.baseList-title")
Log.d("Ppomppu", "찾은 요소: ${elements.size}")
// 최대 20개까지만 처리
var count = 0
elements.forEach { element ->
if (count >= 20) return@forEach
try {
val title = element.text().trim()
if (title.isEmpty()) return@forEach
// 셀렉터로 요소 찾기 - 인기 게시물 감지를 위해 tr 요소 선택
val rowElements: Elements = doc.select("tr.baseList")
Log.d("Ppomppu", "찾은 요소: ${rowElements.size}")
val href = element.attr("href")
// 공지사항 제외
if (href.contains("regulation") || href.contains("notice")) return@forEach
val dealUrl = resolveUrl(baseUrl, href)
// 최대 20개까지만 처리
var count = 0
rowElements.forEach { row ->
if (count >= 20) return@forEach
// postId 추출
val postId = extractPostId(href)
if (postId.isEmpty()) {
Log.w("Ppomppu", "postId 추출 실패: href=$href")
return@forEach
}
try {
// 인기 게시물 여부 확인 (hotpop_bg_color 클래스 존재 여부)
val isPopular = row.hasClass("hotpop_bg_color")
val deal = HotDeal(
id = HotDeal.generateId(siteName, postId),
siteName = siteName,
boardName = board,
title = title,
url = dealUrl,
createdAt = System.currentTimeMillis()
)
deals.add(deal)
count++
Log.d("Ppomppu", "[$count] $title")
} catch (e: Exception) {
Log.e("Ppomppu", "파싱 에러: ${e.message}")
}
}
// 제목 링크 찾기
val titleElement = row.selectFirst("a.baseList-title")
if (titleElement == null) return@forEach
val title = titleElement.text().trim()
if (title.isEmpty()) return@forEach
val href = titleElement.attr("href")
// 공지사항 제외
if (href.contains("regulation") || href.contains("notice")) return@forEach
val dealUrl = resolveUrl(baseUrl, href)
// postId 추출
val postId = extractPostId(href)
if (postId.isEmpty()) {
Log.w("Ppomppu", "postId 추출 실패: href=$href")
return@forEach
}
val deal = HotDeal(
id = HotDeal.generateId(siteName, postId),
siteName = siteName,
boardName = board,
title = title,
url = dealUrl,
createdAt = System.currentTimeMillis(),
isPopular = isPopular
)
deals.add(deal)
count++
val popularMark = if (isPopular) " [인기]" else ""
Log.d("Ppomppu", "[$count]$popularMark $title")
} catch (e: Exception) {
Log.e("Ppomppu", "파싱 에러: ${e.message}")
}
}
Log.d("Ppomppu", "파싱 완료: ${deals.size}")
Result.success(deals)