diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6c5c796..7c94bda 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Django CI/CD +name: Moodico Server on: workflow_dispatch: diff --git a/moodico/moodtest/color_analyzer.py b/moodico/moodtest/color_analyzer.py index d07a7ed..82e9c76 100644 --- a/moodico/moodtest/color_analyzer.py +++ b/moodico/moodtest/color_analyzer.py @@ -7,7 +7,7 @@ def product_result_by_mood(mood): try: mood_zones_path = 'static/data/mood_zones.json' - products_path = 'static/data/all_products_hex_update_tempk=4_2_1_1.json' + products_path = 'static/data/all_products.json' with open(mood_zones_path, 'r', encoding='utf-8') as f: mood_zones = json.load(f) diff --git a/moodico/products/management/commands/advertise_scraper.py b/moodico/products/management/commands/advertise_scraper.py new file mode 100644 index 0000000..47530bc --- /dev/null +++ b/moodico/products/management/commands/advertise_scraper.py @@ -0,0 +1,123 @@ +import json +import os +from django.conf import settings +from django.core.management.base import BaseCommand +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from webdriver_manager.chrome import ChromeDriverManager + + +class Command(BaseCommand): + help = "Scrape products and save JSON under STATIC_ROOT/data/advertise_products.json" + + def handle(self, *args, **options): + chrome_options = webdriver.ChromeOptions() + chrome_options.add_argument("--headless") + chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument("--disable-dev-shm-usage") + chrome_options.add_argument("--disable-gpu") + chrome_options.add_argument( + 'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' + ) + + driver = webdriver.Chrome( + service=Service(ChromeDriverManager().install()), + options=chrome_options + ) + + try: + url = "https://www.oliveyoung.co.kr/store/main/getBestList.do?dispCatNo=900000100100001&fltDispCatNo=10000010002&pageIdx=1&rowsPerPage=10" + driver.get(url) + wait = WebDriverWait(driver, 15) + + # Wait for