-
Notifications
You must be signed in to change notification settings - Fork 3
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
[FEAT] Make cafeteria scrapper #9
Conversation
๐ ์ด์resolve #2 ๐ ๊ฐ์ํ์์๋น ๋ฐ์ดํฐ ๊ตฌ์กฐ SQL์ ์ฉ์ดํ๊ฒ ๋ณ๊ฒฝ ๐ฉโ๐ป ์์ ์ฌํญDateMenu ์ธํฐํ์ด์ค ์์ฑ ์ถํ ์์นจ ์ ๋ ์ถ๊ฐ๋ ๊ฒฝ์ฐ ๊ณ ๋ คํ์ฌ queryselectorAll์ ํ์ฉํด ์์ ํ์ต๋๋ค. โ ์ฐธ๊ณ ์ฌํญ[
{
cafeteria: 0,
date: {},
kind: '์ผํ',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋ฏธ์ด์(ํด๋ฌด)',
menus: [],
price: [ 0 ]
},
{
cafeteria: 0,
date: {},
kind: '์ผํ',
time: '์ ์ฌ์์ฌ',
mainMenu: '๊น์น์ ์ก๋ฎ๋ฐฅ',
menus: [ '๊น๋๊ธฐ', '์ฌ๊ฐ์ด๋ฌต์ ', 'ํฝ์ด๋ฌด๊ตญ' ],
price: [ 4200, 4000 ]
},
{
cafeteria: 0,
date: {},
kind: '์ผํ',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋์ฝ์ธ ๋ผ๋ฉ',
menus: [ '๋ฐฐ์ถ๊น์น', '๋ฐฅ ๋ฐ๊ณต๊ธฐ', '๋จ๋ฌด์ง๋ฌด์นจ' ],
price: [ 4200, 4000 ]
},
{
cafeteria: 0,
date: {},
kind: '์ผํ',
time: '์ ์ฌ์์ฌ',
mainMenu: '์ค์ง์ด๋ณถ์๋น๋น๋ฐฅ',
menus: [ '๋ฐฐ์ถ๊น์น', '๋ฏธ์ญ๊ตญ', '๊ณ๋์ผ์ฑ์ฐ', '์์ ๋ฌ๊ณ ๋๋ผ๋ผ' ],
price: [ 4200, 4000 ]
},
{
cafeteria: 0,
date: {},
kind: '์ผํ',
time: '์ ์ฌ์์ฌ',
mainMenu: '์ง์ฝ๋ฐ์น๋ฐฅ',
menus: [ '๋ฐฐ์ถ๊น์น', '์๊ตฌ๋ฅดํธ', 'ํต๋ฐฐ์ถ๋์ฅ๊ตญ' ],
price: [ 4200, 4000 ]
},
{
cafeteria: 1,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋ฏธ์ด์(ํด๋ฌด)',
menus: [],
price: [ 0 ]
},
{
cafeteria: 1,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๊น์น๋๊ฝ์น์ฆํจ๋ฐ์คํ
์ดํฌ',
menus: [ '๊น๋๊ธฐ', '์๊ตฌ๋ฅดํธ', '์ซ๋ฉด', '๋ฐฐ์ถ๋์ฅ๊ตญ', '์์์ถ์๋ฌ๋/์ ์๋๋ ์ฑ' ],
price: [ 5300, 4900 ]
},
{
cafeteria: 1,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋์ก์ฝฉ๋๋ฌผ๋ถ๊ณ ๊ธฐ',
menus: [ '๋ฐฐ์ถ๊น์น', '๋ค๊นจ๋ฏธ์ญ๊ตญ', '์๋์ฟจํผ์ค', '์ผ์ฑ๊ณ๋์ฐ', 'ํ์คํ์๋ฌ๋' ],
price: [ 5300, 4900 ]
},
{
cafeteria: 1,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋ง์ตธํนํ์์ก',
menus: [ '์ด๋ฌต๋ฌด๊ตญ', '๋ฐฐ์ถ๊น์น', '์๋ฅ์์ด๋', '์ค์ด๋ถ์ถ๋ฌด์นจ', '์ง์ฅ๋ฉด' ],
price: [ 5300, 4900 ]
},
{
cafeteria: 1,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '์ฐ๋ญ',
menus: [ '๋ฐฐ์ถ๊น์น', '๋ฌด์์ฑ', '๊ฐ๊ทค์ฃผ์ค', '๊ฐ์์์ ๋น', '๋๋ถ&๊ฐ์งํ๊น/์น ๋ฆฌ์์ค' ],
price: [ 5300, 4900 ]
},
{
cafeteria: 2,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋ฏธ์ด์(ํด๋ฌด)',
menus: [],
price: [ 0 ]
},
{
cafeteria: 2,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋์ก์ฃผ๋ฌผ๋ญ',
menus: [ '์๊ตฌ๋ฅดํธ', 'ํฌ๊ธฐ๊น์น', '๋์ก์ก์ฑ', '์ด๋ฌต์ ', '๋ถ์ด์ฝฉ๋๋ฌผ๊ตญ', '์๋ฐฐ์ถ์๋ฌ๋/์ค๋ฆฌ์ํ๋๋ ์ฑ' ],
price: [ 7000, 6000 ]
},
{
cafeteria: 2,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '๋ฐ๋ฆฌ์ผ๋ผ๋ญ๋ณถ์',
menus: [ '์๊ตฌ๋ฅดํธ', 'ํฌ๊ธฐ๊น์น', '๊ผฌ์๋๊ธฐ์ผ์ฑ๋ฌด์นจ&์ด๊ณ ์ถ์ฅ', '๋จํธ๋ฐ์ฃฝ', '๋ฉธ์น๋
์ฝฉ๋ณถ์', '๋ฌด์ด๋ฌต๊ตญ' ],
price: [ 7000, 6000 ]
},
{
cafeteria: 2,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '์ทจ๋๋ฌผ๋ฐฅ(์๋
๊ฐ์ฅ)',
menus: [ '์๊ตฌ๋ฅดํธ', 'ํฌ๊ธฐ๊น์น', '๊ณ๋ํ๊ตญ', '๊น๊ตฌ์ด', '๊ณ ๋ฑ์ด์นด๋ ๊ตฌ์ด', '์๊ณ ๊ธฐ์์ฃผ๋ณถ์' ],
price: [ 7000, 6000 ]
},
{
cafeteria: 2,
date: {},
kind: '์ ์',
time: '์ ์ฌ์์ฌ',
mainMenu: '์์ ๊ฐ์ค&ํ๋ฅดํ๋ฅด์์ค',
menus: [ 'ํฌ๊ธฐ๊น์น', '๋ฌด์์ฑ', '์ ๋ถ์ฅ๊ตญ', '๋น๋ฒผ๋จน๋๊ณ๋์ฅ', '์ถ์ต์ํ ๋งํ ์คํ๊ฒํฐ' ],
price: [ 7000, 6000 ]
}
] date๋ถ๋ถ์ ์ฝ์ ์ถ๋ ฅ์ ์ ๋๋ก ๋์ต๋๋ค. ํฐ๋ฏธ๋์ด๋ผ ์ฌ๋ฐ๋ฅด๊ฒ ์ถ๋ ฅ๋์ง ์๋ค์. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ค ์ํ์
จ๋ค์! ๊ณ ์ํ์
จ์ต๋๋ค!! ๊ทผ๋ฐ ์์ง ๋ชฝ๊ณ DB๋ ๊ตฌ์ถ์ ์ด๋ผ์ ๋ชฝ๊ณ DB์ ๊ด๋ จ๋ ์ฌํญ๋ค์ ์ถํ์ ๊ณ ๋ คํ๋๊ฒ ์ข์๋ฏํฉ๋๋ค. ๊ทธ๋ ์คํค๋ง ๊ตฌ์กฐ๋ ๊ฐ์ด ๊ณ ๋ฏผํด๋ณด๋๊ฒ ์ข์๊ฒ ๊ฐ์์.
ํนํ ํ์์๋น๊ณผ ๊ธฐ์์ฌ์๋น์ ๊ฐ์ UI๊ตฌ์กฐ๋ฅผ ์๊ฐํ๊ณ ์์ด์ ์๋ก ๋ง์ถฐ์ผํ ๊ฒ ์ข ์์๊ฒ ๊ฐ๊ตฌ์
๊ทธ๋์ ๋ฐ์ดํฐ ๋ฐํ๊ฐ์ ํ์ฌ ์ฌ์ฉํ๊ณ ์๋ DBํ
์ด๋ธ ๊ตฌ์กฐ์ ๋ง์ถฐ์ #2 ์ ๊ฐ์ ํํ๋ก ๋ง์ถฐ์ฃผ์๋ฉด ์ข์๊ฒ ๊ฐ์์. ์คํฌ๋ํผ๋ ๊ตฌํ์ด ์๋ฃ๋๋ฉด ๋ฐ๋ก ์ฌ์ฉํ๋ ค๊ณ ํ๊ฑฐ๋ ์ค
loadScript(scriptPath: string) { | ||
find.file(/\.js$/, scriptPath, (paths: string[]) => { | ||
for (const path of paths) { | ||
const script = require(path); | ||
this.queue.push(new Scenario(script)); | ||
} | ||
this.loadedScript = true; | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด๋ถ๋ถ์ Scrapper
์ ์๋ ์ฝ๋์ธ๋ฐ ํน์ ์ฎ๊ธฐ์ ์ด์ ๊ฐ ์์๊น์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ 3๋ฒ ๋ฐ๋ก ๊ธ์ด์ผ ํ๋ ์ค ์๊ณ ์ฝ๋ ์ฌ์ฌ์ฉ์ ์ํด์ ํด๋ก์ ๋ก ๋ง๋ค์ด๋ณผ ์๊ฐ์ด์์ต๋๋ค.
๊ทธ๋ฐ๋ฐ ๊ตฌ์กฐ๊ฐ ๊ทธ๋ฅ ํญ ์๋๋ฅด๋ฉด ์จ๊ฒจ์ ธ์๋ค๊ฐ ์ ํ๋๋๊ฑฐ๋๋ผ๊ตฌ์ ์ ๋ณด๊ฐ html์ ๋ค ๋จ์์๊ธธ๋ ๊ทธ๋ฅ ์์ ์ํ๋๋ฐ
๋ค์ ์ง์ฐ๋ ๊ฑธ ๊น๋นกํ๋ค์!
๊ทธ ๊ตฌ์กฐ๋ ๊ฐ๊ฒฉ์ด๋ ์ข
๋ฅ(๋ฐ์ํ์ผ๋ก ๊ฐ๋ก ์ค์ด๋ฉด ๋ฐฑ๋ฐ ์ ์ ํน์ ๋ฑ์ด ๋ค ๋๋๋ ๊ฑธ๋ก ๋ณด์ ๋์ค์ ์ถ๊ฐ๋ ๊ฒ ๊ฐ์ ๋๋์ด..) ์์ด์ ๋ฐ๋ก ๋ง๋ค๊ธด ํด์ผํ ๊ฒ ๊ฐ์๋ฐ ์ด๋ป๊ฒ ํด์ผํ ๊น์?
๋ฐฐ์ด๋ก ๋์ด์๋ ํ๋กํผํฐ๋ค์ ๋ง์ํด์ฃผ์ ๊ตฌ์กฐ๋๋ก |๋ก ๊ตฌ๋ถํด์ ํ ๋ฌธ์์ด๋ก ํฉ์น๋๋กํ๊ฒ ์ต๋๋ค.
์ผ๋จ ๋ง์ํด์ฃผ์ ๋๋ก ์์ ํด์ ๋ค์ ์ปค๋ฐ ์ฌ๋ฆฌ๊ฒ ์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋๋ฉด foreign key๋ก ํ์ฉํ ์ ์๊ฒ primary key๊ฐ์ ์ฐ๊ฒฐ์ํฌ ๊ตฌ์กฐ๋ฅผ ํ๋ ๋ ๋ง๋ค์ด์ ํ๋ ๊ฒ ๋์๊น์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํ .. ๊ทธ๋ฌ๋ค์ ์ง๊ธ์ ํ๋น์๋น์์ ์ผํ๋ฐ์ ์๋ณด์ด๋๋ฐ ๋์ค์ ๋ฐฑ๋ฐ ์ ์์ด๋ ํน์์ด ์ถ๊ฐ๋ ์๋ ์์๊ฒ ๊ฐ๊ตฐ์..
์ผ๋จ ์ง๊ธ์ ํ๋น์๋น(์ผํ)ํ๊ณ (๋ณ๋น,์ํ์)์ ์๋ง ์คํฌ๋ํํ๊ณ ๋ฐฑ๋ฐ์ด ์ถ๊ฐ๋๋ฉด ๊ธฐ์์ฌ ์๋จ๊ณผ UI์ ๋ฐ์ดํฐ ๊ตฌ์กฐ๋ฅผ ๋ค๋ฅด๊ฒ ํด์ผํ๋ ๋ฐฉ๋ฒ๊น์ง๋ ๊ณ ๋ คํด๋ด์ผ๊ฒ ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[
{
restaurant_name: 'ํ๋น ์๋น',
food_name: '๋ฏธ์ด์(ํด๋ฌด)|',
date: '2021-11-11',
time: 1
},
{
restaurant_name: 'ํ๋น ์๋น',
food_name: '๊น์น์ ์ก๋ฎ๋ฐฅ|๊น๋๊ธฐ|์ฌ๊ฐ์ด๋ฌต์ |ํฝ์ด๋ฌด๊ตญ',
date: '2021-11-12',
time: 1
},
{
restaurant_name: 'ํ๋น ์๋น',
food_name: '๋์ฝ์ธ ๋ผ๋ฉ|๋ฐฐ์ถ๊น์น|๋ฐฅ ๋ฐ๊ณต๊ธฐ|๋จ๋ฌด์ง๋ฌด์นจ',
date: '2021-11-13',
time: 1
},
{
restaurant_name: 'ํ๋น ์๋น',
food_name: '์ค์ง์ด๋ณถ์๋น๋น๋ฐฅ|๋ฐฐ์ถ๊น์น|๋ฏธ์ญ๊ตญ|๊ณ๋์ผ์ฑ์ฐ|์์ ๋ฌ๊ณ ๋๋ผ๋ผ',
date: '2021-11-14',
time: 1
},
{
restaurant_name: 'ํ๋น ์๋น',
food_name: '์ง์ฝ๋ฐ์น๋ฐฅ|๋ฐฐ์ถ๊น์น|์๊ตฌ๋ฅดํธ|ํต๋ฐฐ์ถ๋์ฅ๊ตญ',
date: '2021-11-15',
time: 1
},
{
restaurant_name: '๋ณ๋น ์๋น',
food_name: '๋ฏธ์ด์(ํด๋ฌด)|',
date: '2021-11-11',
time: 1
},
{
restaurant_name: '๋ณ๋น ์๋น',
food_name: '๊น์น๋๊ฝ์น์ฆํจ๋ฐ์คํ
์ดํฌ|๊น๋๊ธฐ|์๊ตฌ๋ฅดํธ|์ซ๋ฉด|๋ฐฐ์ถ๋์ฅ๊ตญ|์์์ถ์๋ฌ๋/์ ์๋๋ ์ฑ',
date: '2021-11-12',
time: 1
},
{
restaurant_name: '๋ณ๋น ์๋น',
food_name: '๋์ก์ฝฉ๋๋ฌผ๋ถ๊ณ ๊ธฐ|๋ฐฐ์ถ๊น์น|๋ค๊นจ๋ฏธ์ญ๊ตญ|์๋์ฟจํผ์ค|์ผ์ฑ๊ณ๋์ฐ|ํ์คํ์๋ฌ๋',
date: '2021-11-13',
time: 1
},
{
restaurant_name: '๋ณ๋น ์๋น',
food_name: '๋ง์ตธํนํ์์ก|์ด๋ฌต๋ฌด๊ตญ|๋ฐฐ์ถ๊น์น|์๋ฅ์์ด๋|์ค์ด๋ถ์ถ๋ฌด์นจ|์ง์ฅ๋ฉด',
date: '2021-11-14',
time: 1
},
{
restaurant_name: '๋ณ๋น ์๋น',
food_name: '์ฐ๋ญ|๋ฐฐ์ถ๊น์น|๋ฌด์์ฑ|๊ฐ๊ทค์ฃผ์ค|๊ฐ์์์ ๋น|๋๋ถ&๊ฐ์งํ๊น/์น ๋ฆฌ์์ค',
date: '2021-11-15',
time: 1
},
{
restaurant_name: '์ํ์ ์๋น',
food_name: '๋ฏธ์ด์(ํด๋ฌด)|',
date: '2021-11-11',
time: 1
},
{
restaurant_name: '์ํ์ ์๋น',
food_name: '๋์ก์ฃผ๋ฌผ๋ญ|์๊ตฌ๋ฅดํธ|ํฌ๊ธฐ๊น์น|๋์ก์ก์ฑ|์ด๋ฌต์ |๋ถ์ด์ฝฉ๋๋ฌผ๊ตญ|์๋ฐฐ์ถ์๋ฌ๋/์ค๋ฆฌ์ํ๋๋ ์ฑ',
date: '2021-11-12',
time: 1
},
{
restaurant_name: '์ํ์ ์๋น',
food_name: '๋ฐ๋ฆฌ์ผ๋ผ๋ญ๋ณถ์|์๊ตฌ๋ฅดํธ|ํฌ๊ธฐ๊น์น|๊ผฌ์๋๊ธฐ์ผ์ฑ๋ฌด์นจ&์ด๊ณ ์ถ์ฅ|๋จํธ๋ฐ์ฃฝ|๋ฉธ์น๋
์ฝฉ๋ณถ์|๋ฌด์ด๋ฌต๊ตญ',
date: '2021-11-13',
time: 1
},
{
restaurant_name: '์ํ์ ์๋น',
food_name: '์ทจ๋๋ฌผ๋ฐฅ(์๋
๊ฐ์ฅ)|์๊ตฌ๋ฅดํธ|ํฌ๊ธฐ๊น์น|๊ณ๋ํ๊ตญ|๊น๊ตฌ์ด|๊ณ ๋ฑ์ด์นด๋ ๊ตฌ์ด|์๊ณ ๊ธฐ์์ฃผ๋ณถ์',
date: '2021-11-14',
time: 1
},
{
restaurant_name: '์ํ์ ์๋น',
food_name: '์์ ๊ฐ์ค&ํ๋ฅดํ๋ฅด์์ค|ํฌ๊ธฐ๊น์น|๋ฌด์์ฑ|์ ๋ถ์ฅ๊ตญ|๋น๋ฒผ๋จน๋๊ณ๋์ฅ|์ถ์ต์ํ ๋งํ ์คํ๊ฒํฐ',
date: '2021-11-15',
time: 1
}
]
์๋ฃ ํ ์ปค๋ฐํ์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ค ๋ต ๊ณ ์ํ์
จ์ต๋๋ค. ๊ทผ๋ฐ ํน์ ๋ฉ๋ด ์ด๋ฆ ๊ตฌ๋ถํ ๋ |
๋์ ๋์ด์ฐ๊ธฐ๋ก ๋ฐ๊ฟ์ฃผ์ค ์ ์์๊น์?
๊ทธ๋ฆฌ๊ณ ์ปค๋ฐ ๋ฉ์์ง๋ช
์ {prefix}: {action} {subject} (#{issue_number})
ํํ๋ก ๋ถํ๋๋ฆฝ๋๋ค.
์ฐธ๊ณ : CMI-OSS/common#1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ํ์ต๋๋ค!
@@ -21,9 +32,9 @@ class CafeteriaScrapper extends Scrapper<CafeteriaScript> { | |||
await this.cralwer.goto(cafeteriaScript.url); | |||
await this.cralwer.waitForSelector(cafeteriaScript.waitSelector); | |||
await this.evaluateScript(cafeteriaScript); | |||
await this.cralwer.evaluate(`script.selectCafetera()`); | |||
const menus = await this.cralwer.evaluate(`script.getMenus()`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
menu
์ ํ์
์ Menu[]
๋ผ๊ณ ์๊ฐํด์ฃผ์๋ฉด ๋ ๋ฏํฉ๋๋ค
๐ ์ด์
resolve #2
๐ ๊ฐ์
ํ์์๋น ์คํฌ๋ํผ ์ถ๊ฐ
๐ฉโ๐ป ์์ ์ฌํญ
WeekMenu, DateMenu, Menu ์ธํฐํ์ด์ค ์์ฑ
์ถํ ์์นจ ์ ๋ ์ถ๊ฐ๋ ๊ฒฝ์ฐ ๊ณ ๋ คํ์ฌ queryselectorAll์ ํ์ฉํด ์์ ํ์ต๋๋ค.
โ ์ฐธ๊ณ ์ฌํญ
๊ณต์ ํ ๋ด์ฉ, ์คํฌ๋ฆฐ์ท ๋ฑ์ ๋ฃ์ด ์ฃผ์ธ์.