Skip to content

Commit d62b87e

Browse files
committedSep 20, 2024
FEAT : 웹 크롤러 기능 추가
- WebCrawlerService, WebCrawlerController 추가 - jsoup 의존성 추가
1 parent 806e25b commit d62b87e

File tree

6 files changed

+55
-22
lines changed

6 files changed

+55
-22
lines changed
 

‎.gitmessage.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
################
2+
# <타입> : <제목> 의 형식으로 제목을 아래 공백줄에 작성
3+
# 제목은 50자 이내 / 변경사항이 "무엇"인지 명확히 작성 / 끝에 마침표 금지
4+
# 예) FEAT: 로그인 기능 추가
5+
6+
# 바로 아래 공백은 지우지 마세요 (제목과 본문의 분리를 위함)
7+
8+
################
9+
# 본문(구체적인 내용)을 아랫줄에 작성
10+
# 여러 줄의 메시지를 작성할 땐 "-"로 구분 (한 줄은 72자 이내)
11+
12+
################
13+
# 꼬릿말(footer)을 아랫줄에 작성 (현재 커밋과 관련된 이슈 번호 추가 등)
14+
# 예) Close #7
15+
16+
################
17+
# FEAT: 새로운 기능 추가
18+
# FIX: 버그 수정
19+
# DOCS: 문서 수정
20+
# STYLE: 스타일 관련 기능(코드 포맷팅, 세미콜론 누락, 코드 자체의 변경이 없는 경우)
21+
# REFACTOR: 코드 리팩토링
22+
# TEST: 테스트 코드 추가
23+
# CHORE: 빌드 업무 수정, 패키지 매니저 수정(ex .gitignore 수정 같은 경우)
24+
################

‎build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ dependencies {
2424
implementation("org.springframework.boot:spring-boot-starter-web")
2525
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
2626
implementation("org.jetbrains.kotlin:kotlin-reflect")
27+
implementation("org.jsoup:jsoup:1.15.4")
28+
2729
runtimeOnly("com.mysql:mysql-connector-j")
2830
testImplementation("org.springframework.boot:spring-boot-starter-test")
2931
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")

‎src/main/kotlin/Controller.kt

-21
This file was deleted.

‎src/main/kotlin/com/example/MonitoringSystem/WebConfig.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
66

77
@Configuration
88
class WebConfig : WebMvcConfigurer {
9-
9+
// React와 SpringBoot간 사용하는 포트를 이어주는 코드
1010
override fun addCorsMappings(registry: CorsRegistry) {
1111
registry.addMapping("/api/**")
1212
.allowedOrigins("http://localhost:3000") // React 애플리케이션이 실행되는 주소
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.MonitoringSystem
2+
3+
import org.springframework.web.bind.annotation.GetMapping
4+
import org.springframework.web.bind.annotation.RequestParam
5+
import org.springframework.web.bind.annotation.RestController
6+
7+
@RestController
8+
class WebCrawlerController(private val webCrawlerService: WebCrawlerService) {
9+
@GetMapping("/api/crawl-list")
10+
fun crawlListTags(@RequestParam url: String): List<String> {
11+
return webCrawlerService.crawlMSubjects(url)
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.MonitoringSystem
2+
3+
import org.jsoup.Jsoup
4+
import org.springframework.stereotype.Service
5+
6+
@Service
7+
class WebCrawlerService {
8+
fun crawlMSubjects(url: String): List<String> {
9+
// Jsoup을 사용하여 웹 페이지를 가져옴
10+
val document = Jsoup.connect(url).get()
11+
12+
// HTML의 <h1> 태그에서 텍스트를 추출
13+
return document.select("a._fade_link span.plain_name").map { it.text() }
14+
}
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.