-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#101: 웨일비 데이터 크롤링 추가
- Loading branch information
Showing
8 changed files
with
131 additions
and
2 deletions.
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
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
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,39 @@ | ||
import axios from 'axios'; | ||
import * as cheerio from 'cheerio'; | ||
|
||
export interface WhalebeData { | ||
title: string; | ||
date: string; | ||
imgUrl: string; | ||
} | ||
|
||
export const whalebeCrawling = async (): Promise<WhalebeData[]> => { | ||
const hostname = 'https://whalebe.pknu.ac.kr'; | ||
const whalebeLink = hostname + '/main'; | ||
const whalebeData: WhalebeData[] = []; | ||
|
||
const response = await axios.get(whalebeLink); | ||
const $ = cheerio.load(response.data); | ||
|
||
const programs = $('ul.px-0').find('li'); | ||
if (programs.length < 1) return; | ||
|
||
programs.each((_, element) => { | ||
const imgUrl = hostname + $(element).find('img').attr('src'); | ||
const title = $(element).find('.card-title').text(); | ||
const date = $(element) | ||
.find('.app_date') | ||
.find('.col-12') | ||
.first() | ||
.text() | ||
.split('~')[1] | ||
.trim(); | ||
const tmpData = { | ||
title, | ||
date, | ||
imgUrl, | ||
}; | ||
whalebeData.push(tmpData); | ||
}); | ||
return whalebeData; | ||
}; |
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
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
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
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
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