forked from ckh08045/AutoPercenty
Merge branch 'master' of https://git.cckb9998.synology.me/ckh08045/AutoPercenty
This commit is contained in:
commit
4393525400
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
import random
|
||||
import logging
|
||||
|
|
|
|||
43
build.spec
43
build.spec
|
|
@ -1,43 +0,0 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['build.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='build',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='build',
|
||||
)
|
||||
|
|
@ -4,3 +4,5 @@ port = 27017
|
|||
user = root
|
||||
password = 1234
|
||||
|
||||
[Playwright]
|
||||
PlaywrightBrowsersPath = ./Lib/site-packages/my_playwright_browsers
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class AutoPercentyProductsDB:
|
|||
steps = {'tag_modification': 'incomplete',
|
||||
'option_modification': 'incomplete',
|
||||
'detail_page_modification': 'incomplete',
|
||||
'thumbnail_modification': 'incomplete'
|
||||
# 'thumbnail_modification': 'incomplete',
|
||||
# 'price_modification': 'incomplete',
|
||||
# 'thumbnail_modification': 'incomplete'
|
||||
'thumbnail_modification': 'incomplete',
|
||||
'price_modification': 'incomplete',
|
||||
# 'title_modification': 'incomplete'
|
||||
}
|
||||
document = {'product_id': product_id, 'process_steps': steps, 'user': user, 'created_at': datetime.now()}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -630,7 +630,7 @@ def modify_detail_page(driver, product_info, gemini, translator, delv_collection
|
|||
|
||||
if trans_img_tag:
|
||||
logger.debug("상세페이지 이미지 번역 시작")
|
||||
for i in range 20:
|
||||
for i in range(20):
|
||||
detail_content.send_keys(Keys.PAGE_DOWN)
|
||||
|
||||
detail_content.send_keys(Keys.HOME)
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ def modify_price_page(driver, product_infos):
|
|||
|
||||
try:
|
||||
save_xpath="//button[contains(.,'저장하기')]"
|
||||
click_element(driver, 'XPATH', save_xpath, 10)
|
||||
click_element(driver, 'XPATH', save_xpath, 10, 'js')
|
||||
logger.debug("가격 정리 후 저장버튼 클릭 완료")
|
||||
except Exception as e:
|
||||
logger.error(f"가격 정리 저장버튼 클릭 중 에러 발생 {e}", exc_info=True)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# 가상 환경 내 site-packages 경로 설정
|
||||
playwright_path = os.path.join(sys.prefix, 'Lib', 'site-packages', 'playwright', 'browsers')
|
||||
os.environ['PLAYWRIGHT_BROWSERS_PATH'] = playwright_path
|
||||
|
||||
# Playwright 설치
|
||||
subprocess.run([sys.executable, '-m', 'pip', 'install', 'playwright'], check=True)
|
||||
subprocess.run(['playwright', 'install'], check=True)
|
||||
19
main.py
19
main.py
|
|
@ -11,7 +11,6 @@ import atexit
|
|||
import platform, os, sys
|
||||
|
||||
from login import login
|
||||
import sys
|
||||
from navigate import navigate_to_new_product_registration
|
||||
from modify_products import modify_products
|
||||
from database import setup_database
|
||||
|
|
@ -26,6 +25,22 @@ from PyQt5 import QtCore, QtWidgets
|
|||
from logger_module import setup_logger
|
||||
import logging
|
||||
|
||||
def set_playwright_path():
|
||||
# 패킹된 애플리케이션의 임시 디렉터리 경로를 확인
|
||||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
|
||||
# PyInstaller 패킹 후 실행 시
|
||||
base_path = sys._MEIPASS
|
||||
playwright_path = os.path.join(base_path, 'playwright', 'browsers')
|
||||
|
||||
else:
|
||||
# 로컬 개발 환경
|
||||
base_path = os.path.dirname(__file__)
|
||||
playwright_path = os.path.join(base_path, 'Lib', 'site-packages', 'playwright', 'browsers')
|
||||
|
||||
# Playwright 브라우저 경로 설정
|
||||
os.environ['PLAYWRIGHT_BROWSERS_PATH'] = playwright_path
|
||||
print(f"Playwright browsers path set to: {playwright_path}")
|
||||
|
||||
# Windows SetThreadExecutionState API를 사용하여 절전 모드 방지
|
||||
def prevent_sleep_mode():
|
||||
"""
|
||||
|
|
@ -199,6 +214,6 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
CURRENT_VERSION = "1.0.0"
|
||||
|
||||
set_playwright_path()
|
||||
logger = setup_logger('default_logger', 'application.log', level=logging.DEBUG)
|
||||
main()
|
||||
|
|
@ -20,6 +20,7 @@ a = Analysis(
|
|||
(os.path.join(spec_dir, 'Lib', 'site-packages', 'paddle', 'libs', '*.dll'), 'paddle\\libs'),
|
||||
(os.path.join(spec_dir, 'Lib', 'site-packages', 'selenium_stealth'), 'selenium_stealth'),
|
||||
(os.path.join(spec_dir, 'Lib', 'site-packages', 'fake_useragent'), 'fake_useragent'),
|
||||
(os.path.join(spec_dir, 'Lib', 'site-packages', 'playwright'), 'playwright'),
|
||||
(os.path.join(spec_dir, 'config.ini'), '.'),
|
||||
(os.path.join(spec_dir, 'Percenty_SS_Code.json'), '.'),
|
||||
(os.path.join(spec_dir, 'NotoSansKR-Bold.ttf'), '.'),
|
||||
|
|
|
|||
|
|
@ -346,22 +346,24 @@ def modify_products(driver, gemini, translator, mongo_config, login_info, set_nu
|
|||
|
||||
# # product_title_element = driver.find_element(By.XPATH, (f"//div[{i}]/li/div/div/div[2]/div/div/div/div"))
|
||||
# driver.execute_script("arguments[0].click();", product_title_element)# 상품 수정 페이지 자바스크립트로 열기
|
||||
|
||||
click_to_product_title_for_modify_xpath = f"//div[{i}]/li/div/div/div[2]/div/div/div/div"
|
||||
click_element(driver, 'XPATH', click_to_product_title_for_modify_xpath, 10, 'js')
|
||||
logger.debug("상품 수정 페이지 클릭")
|
||||
time.sleep(0.3)
|
||||
|
||||
|
||||
tao_title_text_xpath = "//div[@id='productMainContentContainerId']/div/div/div[6]/div/div/span"
|
||||
tao_title = return_element(driver, 'XPATH', tao_title_text_xpath, 10)
|
||||
logger.debug(f"tao_title 텍스트 : {tao_title.text}")
|
||||
product_infos[i-1].tao_title = tao_title.text
|
||||
|
||||
# 상품수정 페이지에 표시된 퍼센티카테고리 텍스트 수집
|
||||
per_cat = return_element(driver, 'XPATH', '//div[8]/div/div/div[2]/div/div/div/span[2]/div/div', 10)
|
||||
logger.debug(f"퍼센티 등록 화면에 표시된 카테고리 텍스트 : {per_cat.text}")
|
||||
product_infos[i-1].per_cat_code = per_cat.text
|
||||
try:
|
||||
click_to_product_title_for_modify_xpath = f"//div[{i}]/li/div/div/div[2]/div/div/div/div"
|
||||
click_element(driver, 'XPATH', click_to_product_title_for_modify_xpath, 10, 'js')
|
||||
logger.debug("상품 수정 페이지 클릭")
|
||||
time.sleep(0.3)
|
||||
|
||||
|
||||
tao_title_text_xpath = "//div[@id='productMainContentContainerId']/div/div/div[6]/div/div/span"
|
||||
tao_title = return_element(driver, 'XPATH', tao_title_text_xpath, 10)
|
||||
logger.debug(f"tao_title 텍스트 : {tao_title.text}")
|
||||
product_infos[i-1].tao_title = tao_title.text
|
||||
|
||||
# 상품수정 페이지에 표시된 퍼센티카테고리 텍스트 수집
|
||||
per_cat = return_element(driver, 'XPATH', '//div[8]/div/div/div[2]/div/div/div/span[2]/div/div', 10)
|
||||
logger.debug(f"퍼센티 등록 화면에 표시된 카테고리 텍스트 : {per_cat.text}")
|
||||
product_infos[i-1].per_cat_code = per_cat.text
|
||||
except Exception as e:
|
||||
logger.debug(f"상품 수정 페이지 클릭과 Tao_Title_Text 요소 찾는 중 오류 발생: {e}", exc_info=True)
|
||||
|
||||
|
||||
# # 이미지 주소 복사
|
||||
|
|
|
|||
Loading…
Reference in New Issue