[์นด์นด์˜ค๋ทฐ] ๋ณด๋“œ ์ž๋™ ๋ฐœํ–‰ 3๋‹จ๊ณ„. nodeJS๋กœ selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉํ•˜์—ฌ ์นด์นด์˜ค๋ทฐ - ์ฑ„๋„ ์ž๋™ ๋กœ๊ทธ์ธ ํ•˜๊ธฐ
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋””์ง€ํ„ธ ๊ฟ€ํŒ

[์นด์นด์˜ค๋ทฐ] ๋ณด๋“œ ์ž๋™ ๋ฐœํ–‰ 3๋‹จ๊ณ„. nodeJS๋กœ selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉํ•˜์—ฌ ์นด์นด์˜ค๋ทฐ - ์ฑ„๋„ ์ž๋™ ๋กœ๊ทธ์ธ ํ•˜๊ธฐ

by ์ผ์ƒ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค 2022. 3. 30.

python๋„ ์ข‹์ง€๋งŒ nodejs๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณด๋“œ๋ฐœํ–‰์„ ์ž๋™ํ™” ํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค. ์˜ค๋Š˜ ๋‚ด์šฉ์—๋Š” ๋กœ๊ทธ์ธ๊นŒ์ง€๋งŒ ๊ธฐ์žฌํ•˜๊ณ , ์˜์ƒ์€ ๋ง›๋ณด๊ธฐ๋กœ ์ƒ˜ํ”Œ ์˜ˆ์ œ๋กœ ๊ณต๊ฐœ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ์ดˆ๋ณด์ž๋Š” ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์ง€๋งŒ ์ตœ๋Œ€ํ•œ ๋งŽ์€ ์ˆ˜์ •์„ ํ†ตํ•ด ์‰ฝ๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ž‘์„ฑํ•˜๋„๋ก ๋…ธ๋ ฅํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ €์˜ PC ํ™˜๊ฒฝ์€ Mac์˜ bigsur(OS 11) ์ž…๋‹ˆ๋‹ค.

 

 

Node JS ,express ํŒจํ‚ค์ง€๋กœ ์›น์„œ๋ฒ„ ๊ตฌ๋™ํ•˜๊ธฐ

์›น์„œ๋ฒ„๋ฅผ ๊ตฌ์ถ•ํ•˜๊ฒŒ๋œ ๋™๊ธฐ ์นด๋ทฐ ์ž๋™ํ™”๋ฅผ ์ƒ๊ฐํ•˜๋‹ค๊ฐ€ ๋ณดํ†ต์€ Selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋•Œ๋ฌธ์— node ,python์„ ์‚ฌ์šฉํ•ด์„œ ์›น์„ ์ปจํŠธ๋กค ํ•˜๋Š”๋ฐ ์–ด์ฐจํ”ผ ๋‹ค ๊ตฌ๊ธ€์—์„œ ๋งŒ๋“ ๊ฑฐ๋‹ˆ๊นŒ GAS (Google App Script) ๋กœ Chrome์„

odaily.tistory.com

 

1๋‹จ๊ณ„ .NodeJS์™€ Visual code ์„ค์น˜

๐Ÿ‘† ์œ„ ๋งํฌ๋ฅผ ๋ณด์•˜๋‹ค๋ฉด visual code ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜์™€ nodejs ๋‹ค์šด๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค. express install์€ ์•ˆํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค

 

2๋‹จ๊ณ„. Selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ Chrome driver๋ฅผ ์„ค์น˜

ํ„ฐ๋ฏธ๋„ ์‹คํ–‰๋ฐฉ๋ฒ• : command + space > ํ„ฐ๋ฏธ๋„ ๊ฒ€์ƒ‰ํ•˜์—ฌ Selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

npm install selenium

- Chromedriver ์„ค์น˜ ํ›„ ํŒŒ์ผ ์œ„์น˜ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.(๋‹ค์šด๋กœ๋“œ ๋งํฌ : https://chromedriver.storage.googleapis.com/index.html?path=100.0.4896.60/)

mv chromedriver /usr/local/binโ€‹

* ์›๋ž˜๋Š” ๋ช…๋ น์–ด๋กœ ์„ค์น˜ํ•ด๋„ ๋˜๋Š”๋ฐ, ๊ฐ„ํ˜น ๋ฒ„์ „์„ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด ๋งํฌ๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.๋‹ค๋ฅธ ์›น๋ธŒ๋ผ์šฐ์ €๋„ ๋งŽ์ด ์‚ฌ์šฉํ•˜์ง€๋งŒ ์šฐ๋ฆฌ๋Š” Chrome์ด ์ต์ˆ™ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํฌ๋กฌ์œผ๋กœ driver๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

brew install --cask chromedriver

 

 

3๋‹จ๊ณ„. visual code ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜์—ฌ selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์„ค์น˜๋œ ํด๋”๋ฅผ ์—ด๊ณ  ์ƒˆ๋กœ์šด ํŒŒ์ผ ์ƒ์„ฑ

3-1. ๋ฌธ์„œ ์ƒ์„ฑ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.
3-2. selenium_test.js ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค. ํ™•์žฅ์ž๋Š” ๊ผญ js๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
3-3. ์•„๋ž˜ ์†Œ์Šค๋ฅผ selenium_test.js ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ ๋„ฃ๊ณ  CTRL+S(์ €์žฅ)ํ•ฉ๋‹ˆ๋‹ค.

const webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until,
    Key = webdriver.Key;

const driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();

driver.get('https://creators.kakao.com/channel/๋ณธ์ธ์ฑ„๋„ID/board/create').then(function(){

    let inputId = driver.findElement(By.css('input#id_email_2')); 
    inputId.sendKeys('์นด์นด์˜คID'); 
    
    let inputpw = driver.findElement(By.css('input#id_password_3')); 
    inputpw.sendKeys('๋น„๋ฐ€๋ฒˆํ˜ธ', Key.ENTER);
    
});
๋ฐ˜์‘ํ˜•


๐Ÿšจ ์œ„ ์†Œ์Šค ์ฐธ๊ณ  ์‹œ ์ฃผ์˜ ์‚ฌํ•ญ๐Ÿšจ
- ๋ณธ์ธ ์นด์นด์˜ค๋ทฐ ์ฑ„๋„ ID๋ฅผ ์ฐพ์•„์„œ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

- ๋ณธ์ธ ์นด์นด์˜ค ๋กœ๊ทธ์ธ ID๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค
- ๋ณธ์ธ ์นด์นด์˜ค ๋กœ๊ทธ์ธ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.


๐Ÿ ์นด์นด์˜ค 2๋‹จ๊ณ„ ์ธ์ฆ์€ ํ’€์–ด์•ผ ํ•œ๋‹ค. ์นด์นด์˜ค ๋ฉ”์‹œ์ง€๋กœ ๋กœ๊ทธ์ธ ์ •๋ณด๋Š” ๋ฐ›์•„๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- ์นด์นด์˜ค ์„ค์ • > ๊ฐœ์ธ/๋ณด์•ˆ/ > ์นด์นด์˜ค ๊ณ„์ • > 2๋‹จ๊ณ„ ์ธ์ฆ > ํ•ด์ œํ•˜๊ธฐ

 

4๋‹จ๊ณ„. ํ„ฐ๋ฏธ๋„์„ ์‹คํ–‰ํ•˜์—ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜๋œ ์œ„์น˜๋กœ ์ด๋™ ํ•˜์—ฌ ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์น˜๋ฉด ์ž๋™ ๋กœ๊ทธ์ธ ์„ฑ๊ณต

- ๋ช…๋ น์–ด๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. 

//์œ„์น˜ ์ด๋™
cd node_modules 
cd selenium-webdriver 

//ํŒŒ์ผ ์‹คํ–‰
node selenium_test.js

 

๋ง›๋ณด๊ธฐ ์˜์ƒ

 

 

[์นด์นด์˜ค๋ทฐ] ๋ณด๋“œ ์ž๋™ ๋ฐœํ–‰ 4๋‹จ๊ณ„, ์œ ํŠœ๋ธŒ(Youtube) API ์‚ฌ์šฉํ•˜์—ฌ ๊ฒ€์ƒ‰ ํ‚ค์›Œ๋“œ๋กœ ์˜์ƒ ๊ฐ€์ ธ์˜ค๊ธฐ , googl

์นด์นด์˜ค๋ทฐ ์ž๋™ ๋ฐœํ–‰์„ ๊ณ ๋ฏผํ•˜๋ฉด์„œ ๋‹ค์Œ ๋‰ด์Šค N๊ฐœ, ๋„ค์ด๋ฒ„ ๋‰ด์Šค N๊ฐœ, ํ‹ฐ์Šคํ† ๋ฆฌ N๊ฐœ, ๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ N๊ฐœ, ์œ ํŠœ๋ธŒ N๊ฐœ ์ด๋ ‡๊ฒŒ ์„ค์ •ํ•˜์—ฌ ๋ฐœํ–‰ ๊ฐ€๋Šฅํ•˜๋„๋ก ์ƒ๊ฐํ•˜์˜€๋‹ค. ๋งค์ผ 00:00๋ฉด ์ˆ˜๋™์œผ๋กœ playlist ๋ณด๋“œ

odaily.tistory.com

 

[์นด์นด์˜ค๋ทฐ] ๋ณด๋“œ ์ž๋™ ๋ฐœํ–‰ 5๋‹จ๊ณ„, ์ž๋™ ๋ฐœํ–‰ (์˜ค๋ฅ˜๊ฐ€ ์ข…์ข… ๋ฐœ์ƒํ•˜๋Š” ์ฝ”๋“œ)

์ง€๋‚œ 3์›” ๋ง์— ๋กœ๊ทธ์ธ๊นŒ์ง€๋งŒ ์ž‘์—…ํ•˜๊ณ , ๊ทธ ์ดํ›„ ์ž‘์—…์— ๋Œ€ํ•ด ์˜ค๋ž˜ ๊ฑธ๋ ธ์Šต๋‹ˆ๋‹ค. ์ž‘์—…์„ ํ•˜์—ฌ ์ž๋™๋ฐœํ–‰์„ ํ–ˆ๋Š”๋ฐ๋„ ๋ณด๋“œ๊ฐ€ ์ €ํ’ˆ์งˆ์ด ๊ฑธ๋ ธ์Šต๋‹ˆ๋‹ค ๊ทธ๋ž˜์„œ ๋…ธ์ถœ์ˆ˜๊ฐ€ 1/1000์œผ๋กœ ์ค„์–ด์„œ ์†์ƒํ•˜์ง€๋งŒ, ๋‹ค

odaily.tistory.com

 

ํ•ด๋‹น ์˜์ƒ์€ ์นด์นด์˜ค ๋กœ๊ทธ์ธ ํ›„ ์ฑ„๋„์—์„œ ์ œ๋ชฉ/๋‚ด์šฉ/๋งํฌ๊นŒ์ง€ ๋‹ด์•„๋ณด๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. ์ง€๊ธˆ๋„ ๊พธ์ค€ํžˆ ์ž‘์—…ํ•ด๋ณด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ ์œ ์ €์ž…์žฅ์—์„œ ์–ด๋–ป๊ฒŒํ•ด์•ผ ์ •๋ง ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ์œผ๋กœ ๋™์ž‘ํ• ์ง€์— ๋Œ€ํ•œ ์ƒ๊ฐ์ด ๋งŽ์•„ 4~5๋‹จ๊ณ„ ๊ฒŒ์‹œ๊ธ€์ด ๋Šฆ์–ด์ง€๋Š” ์  ์–‘ํ•ด๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. 

 

 

๋Œ“๊ธ€