File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed
main/java/org/tuna/zoopzoop/backend/domain/datasource/crawler/service
test/java/org/tuna/zoopzoop/backend/domain/datasource/crawler/service Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,13 @@ public LocalDate transLocalDate(String rawDate) {
5151 if (rawDate .contains ("일 전" )){
5252 int daysAgo = Integer .parseInt (rawDate .split ("일 전" )[0 ].trim ());
5353 return LocalDate .now ().minusDays (daysAgo );
54- }else if (rawDate .contains ("방금 전" )) {
55- return LocalDate .now ();
56- }else if (rawDate .contains ("시간 전" )||rawDate .contains ("분 전" )){
54+ }else if (rawDate .contains ("시간 전" )||rawDate .contains ("방금 전" )||rawDate .contains ("분 전" )){
5755 return LocalDate .now ();
56+ }else if (rawDate .contains ("어제" )){
57+ return LocalDate .now ().minusDays (1 );
5858 }
5959
60+
6061 return LocalDate .parse (rawDate , VELOG_FORMATTER );
6162 }
6263}
Original file line number Diff line number Diff line change 11package org .tuna .zoopzoop .backend .domain .datasource .crawler .service ;
22
3+ import org .jsoup .Jsoup ;
4+ import org .jsoup .nodes .Document ;
5+ import org .junit .jupiter .api .Test ;
6+ import org .tuna .zoopzoop .backend .domain .datasource .crawler .dto .CrawlerResult ;
7+
8+ import java .io .IOException ;
9+
10+ import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
11+
312class VelogCrawlerTest {
413
514 private final VelogCrawler velogCrawler = new VelogCrawler ();
615
7- // 날짜 바뀐 velog 포스트에 대해 에러 처리 필요
8- // Text '어제' could not be parsed at index 0
9- // java.time.format.DateTimeParseException
10- // @Test
11- // void testExtract() throws IOException {
12- // Document doc = Jsoup.connect("https://velog.io/@hyeonnnnn/VampireSurvivorsClone-04.-PoolManager").get();
13- // CrawlerResult<?> result = velogCrawler.extract(doc);
14- // assertThat(result).isNotNull();
15- //
16- // System.out.println(result);
17- // }
16+ @ Test
17+ void testExtract () throws IOException {
18+ Document doc = Jsoup .connect ("https://velog.io/@imcute0703123/%EC%BA%A0%ED%8D%BC%EC%8A%A4%EC%8B%9C%EA%B7%B8%EB%84%90-2025-%EB%B0%B1%EC%84%9D%EC%97%B0%ED%99%94-1%EB%93%B1-%EB%B6%80%EC%8A%A4-%EB%9F%AC%EB%B8%8C%EB%9D%BC%EC%9D%B8-%EB%A7%A4%EC%B9%AD-%EC%84%9C%EB%B9%84%EC%8A%A4-%ED%9A%8C%EA%B3%A0%EB%A1%9D" ).get ();
19+ CrawlerResult <?> result = velogCrawler .extract (doc );
20+ assertThat (result ).isNotNull ();
21+
22+ System .out .println (result );
23+ }
1824}
You can’t perform that action at this time.
0 commit comments