Compare commits

...

7 Commits

Author SHA1 Message Date
R5600U_PC 5e7b430689 카피맨 카테고리 비어있는 부분 처리 2024-06-03 07:37:52 +09:00
Envy_PC 06c01c6d90 타오파서 대폭수정. 2024-04-29 21:51:17 +09:00
Envy_PC 844366938d 캡차 세분류, log함수 잘못된 사용 수정 2024-04-28 18:29:26 +09:00
Envy_PC c856ce4045 merged_price 표시되게 수정 2024-04-22 12:09:30 +09:00
Envy_PC e5e153777e 엑셀파일 저장 시 카피맨,소싱맨은 해당가격을,
키워드소싱은 평균가격을 플로스피로 입력.
배송비는 0원처리.
2024-04-22 12:03:32 +09:00
Envy_PC af186266b3 소싱맨 카피맨처럼 가격을 미리 가져올 경우 해당 가격에서2%내린 가격으로 등록 및 배송비 0원 처리 2024-04-22 11:48:54 +09:00
Envy_PC d10feb6069 캡차방식 세분화(스크래치와 슬라이드) 2024-04-22 11:16:37 +09:00
10 changed files with 948 additions and 525 deletions

View File

@ -82,6 +82,7 @@ def create_db(db_name):
tao_imageUrl TEXT,
tao_itemID INTEGER,
tao_localimage TEXT,
merged_price INTEGER,
unique_id TEXT,
date_created TEXT DEFAULT (DATE('now', 'localtime')),
time_created TEXT DEFAULT (TIME('now', 'localtime')),

View File

@ -95,7 +95,6 @@ def automatch(db, item_count, message_controller, sort_order, progress_callback=
for i, product in enumerate(products):
logger.debug(f"{i}번째 product 정보 DB 업데이트 준비")
itemUrl, itemID, imageUrl, item_name, price, sales_volume = product
# DB에 상품 정보 업데이트
update_query = """
INSERT INTO Taobao (keyword_id, itemUrl, itemID, imageUrl, item_name, price, sales_volume)
@ -105,7 +104,7 @@ def automatch(db, item_count, message_controller, sort_order, progress_callback=
cursor.execute(update_query, (keyword_id, itemUrl, itemID, imageUrl, item_name, price, sales_volume))
logger.debug(f"TaoBao 테이블에 [{product}/{len(products)}] 내용 업데이트 실행")
except Exception as e:
logger.debug(f"product 정보 DB 업데이트 중 오류 발생 : {e}")
logger.debug(f"product 정보 DB 업데이트 중 오류 발생 : {e}", exc_info=True)
logger.debug(f"{len(products)}개의 product 정보 DB 업데이트 완료")
@ -120,7 +119,19 @@ def automatch(db, item_count, message_controller, sort_order, progress_callback=
# for index, (row, product) in enumerate(zip(group.iterrows(), products[:product_count])):
for index, (row, product) in enumerate(zip(group.itertuples(index=False), products[:product_count])):
itemUrl, itemID, imageUrl, item_name, price, sales_volume = product
# itemUrl, itemID, imageUrl, item_name, price, sales_volume = product # 튜플일때
# 상품 정보 추출 #리스트일때
itemUrl = product['Product URL']
itemID = product['Tao_itemID']
imageUrl = product['Image URL']
item_name = product['Product Name']
price = product['Price']
sales_volume = product['Sales Volume']
if price == '' and itemID =='':
continue
if keyword_id != row.keyword_id:
continue
@ -154,7 +165,7 @@ def automatch(db, item_count, message_controller, sort_order, progress_callback=
# PC 주소 생성
match = re.search(r'taobao.com/i(\d{10,12})', itemUrl)
pc_url = f"https://item.taobao.com/item.htm?id={match.group(1)}" if match else ""
# NaverShopping 테이블에 매칭 정보 업데이트
update_ns_query = """
UPDATE NaverShopping

View File

@ -37,30 +37,25 @@ def load_cookies(driver):
logger.debug(f"쿠키 로드 중 기타 에러 발생 : {e}")
return False
def check_login_status_ori(driver):
# 로그인되지 않은 상태의 XPath
not_logged_in_xpath = "//li[@id='J_SiteNavLogin']/div/div/a"
# 로그인된 상태의 XPath
# logged_in_xpath = "//li[@id='J_SiteNavLogin']/div/div[2]/a"
def check_login_status_by_iframe(driver):
logged_in_xpath = "/html/body/div[1]/div/ul[1]/li[2]/div[1]/div[2]/a"
# # 로그인되지 않은 상태 확인
# if WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, not_logged_in_xpath))):
# logger.debug("로그인되지 않았습니다. 로그인이 필요합니다.")
# return False
logger.debug("로그인된 상태 확인")
# 로그인된 상태 확인
if WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, logged_in_xpath))):
user_id_text = driver.find_element(By.XPATH, logged_in_xpath).text
logger.debug(f"로그인된 상태입니다. 로그인된 ID: {user_id_text}")
return True
# 로그인되지 않은 상태 확인
elif WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, not_logged_in_xpath))):
logger.debug("로그인되지 않았습니다. 로그인이 필요합니다.")
return False
else:
logger.debug("로그인 상태를 확인할 수 없습니다.")
return False
while True:
try:
logger.debug("로그인된 상태 확인 중...")
# 로그인된 상태 확인
if driver.find_element(By.XPATH, logged_in_xpath):
user_id_text = driver.find_element(By.XPATH, logged_in_xpath).text
logger.debug(f"로그인된 상태입니다. 로그인된 ID: {user_id_text}")
return True
except:
# 로그인되지 않은 상태 확인
try:
logger.debug("로그인되지 않았습니다. 로그인이 필요합니다.")
time.sleep(5) # 5초 후 다시 체크
except:
logger.debug("로그인 상태를 확인할 수 없습니다. 잠시 후 다시 시도합니다.")
time.sleep(5) # 예외 발생 시 5초 대기 후 재시도
def check_login_status(driver):

File diff suppressed because it is too large Load Diff

View File

@ -151,8 +151,18 @@ def parse_naver_shopping(keyword_id, keyword, isBranch, branchCount, json_data,
final_top_5_products = top5_products[:5]
logger.debug(f"RANK 정렬상품 중 마지막으로 상위 제품 [{len(final_top_5_products)}]개 선택")
merged_price = 0
for index, product in enumerate(final_top_5_products):
price = int(product.get("item", {}).get("price"))
merged_price += price # 평균 가격 계산을 위해
merged_price = merged_price / len(final_top_5_products)
c = conn.cursor()
# original relatedTags 리스트 가져오기
related_tags_ori = next_data_json["props"]["pageProps"]["relatedTags"]
@ -245,8 +255,8 @@ def parse_naver_shopping(keyword_id, keyword, isBranch, branchCount, json_data,
if count == 0:
# 중복되는 데이터가 없으면 새로운 데이터 삽입
c.execute("INSERT INTO NaverShopping (keyword_id, keyword, price, productTitle, category1Name, category2Name, category3Name, category4Name, cat_code, openDate, mallCount, keepCnt, overseaTp, reviewCount, reviewCountSum, scoreInfo, naverPayAdAccumulatedDisplayValue, mobileLowPrice, lowPrice, deliveryFeeContent, dlvryLowPrice, imageUrl, imgSz, searchKeyword, mallProductUrl, mallPcUrl, mallName, manuTag, purchaseCnt, relatedTags, rank, unique_id, date_created, time_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(keyword_id+1, current_keyword, price, productTitle, category1Name, category2Name, category3Name, category4Name, cat_code, openDate, mallCount, keepCnt, overseaTp, reviewCount, reviewCountSum, scoreInfo, naverPayAdAccumulatedDisplayValue, mobileLowPrice, lowPrice, deliveryFeeContent, dlvryLowPrice, imageUrl, imgSz, searchKeyword, mallProductUrl, mallPcUrl, mallName, manuTag, purchaseCnt, current_keyword, rank, unique_id, date_created, time_created)) # keyword_id, item_name, price, purchase_count, related_keywords, rank는 적절하게 설정해야 합니다.
c.execute("INSERT INTO NaverShopping (keyword_id, keyword, price, productTitle, category1Name, category2Name, category3Name, category4Name, cat_code, openDate, mallCount, keepCnt, overseaTp, reviewCount, reviewCountSum, scoreInfo, naverPayAdAccumulatedDisplayValue, mobileLowPrice, lowPrice, deliveryFeeContent, dlvryLowPrice, imageUrl, imgSz, searchKeyword, mallProductUrl, mallPcUrl, mallName, manuTag, purchaseCnt, relatedTags, rank, merged_price, unique_id, date_created, time_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(keyword_id+1, current_keyword, price, productTitle, category1Name, category2Name, category3Name, category4Name, cat_code, openDate, mallCount, keepCnt, overseaTp, reviewCount, reviewCountSum, scoreInfo, naverPayAdAccumulatedDisplayValue, mobileLowPrice, lowPrice, deliveryFeeContent, dlvryLowPrice, imageUrl, imgSz, searchKeyword, mallProductUrl, mallPcUrl, mallName, manuTag, purchaseCnt, current_keyword, rank, merged_price, unique_id, date_created, time_created)) # keyword_id, item_name, price, purchase_count, related_keywords, rank는 적절하게 설정해야 합니다.
logger.debug(f"{current_keyword} DB업데이트 완료")
else:
# 중복되는 데이터가 있으면 업데이트 또는 무시 (여기서는 예시로 업데이트 로직을 추가함)
@ -259,4 +269,5 @@ def parse_naver_shopping(keyword_id, keyword, isBranch, branchCount, json_data,
logger.debug(f"키워드 검색 결과 상품 [{keyword}]에 대한 [{len(final_top_5_products)}]개의 상품정보수집 완료")
conn.commit() # Commit the transaction
#conn.close() # Close the connection

View File

@ -160,7 +160,7 @@
열기</string>
</property>
</widget>
<widget class="QPushButton" name="export_btn">
<widget class="QPushButton" name="export_btn_by_branch">
<property name="geometry">
<rect>
<x>360</x>
@ -314,7 +314,7 @@ XLS저장</string>
<string>Save Image</string>
</property>
</widget>
<widget class="QPushButton" name="export_btn_by_auto">
<widget class="QPushButton" name="export_btn_by_main">
<property name="geometry">
<rect>
<x>360</x>

Binary file not shown.

View File

@ -32,6 +32,6 @@ class TaoScrapingThread(QThread):
logger.debug("Automatch 작업 완료")
except Exception as e:
logger.error(f"Automatch 스레드에서 오류 발생: {e}")
logger.error(f"Automatch 스레드에서 오류 발생: {e}", exc_info=True)
finally:
self.finished.emit()

View File

@ -81,7 +81,7 @@ def update_db(db_name, query, params):
conn.commit()
except Exception as e:
conn.rollback()
print(f"Failed to update database: {e}")
print(f"Failed to update database: {e}", exc_info=True)
return False
return True
@ -174,7 +174,7 @@ class PandasModel(QAbstractTableModel):
self._data.reset_index(drop=True, inplace=True)
self.layoutChanged.emit()
except Exception as e:
print(f"Error sorting data: {e}")
print(f"Error sorting data: {e}", exc_info=True)
def setData(self, index, value, role=Qt.EditRole):
if not index.isValid():
@ -233,7 +233,7 @@ class PandasModel(QAbstractTableModel):
connection.commit()
except Exception as e:
connection.rollback()
print(f"Failed to update database: {e}")
print(f"Failed to update database: {e}", exc_info=True)
finally:
connection.close()
@ -466,8 +466,8 @@ class Ui_Dialog(QtWidgets.QDialog):
self.db_btn.clicked.connect(self.loadExistingDb)
# db를 엑셀로 저장 버튼
self.export_btn.clicked.connect(self.export_data)
self.export_btn_by_auto.clicked.connect(self.export_data_by_auto)
self.export_btn_by_branch.clicked.connect(self.export_data_by_branch)
self.export_btn_by_main.clicked.connect(self.export_data_by_main)
# 불러와진 DB에서 테이블을 읽어서 콤보박스에 표시하기
@ -567,7 +567,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.automatch_thread.finished.connect(self.on_automatch_finished) # automatch 작업 완료 후 처리
self.automatch_thread.start()
except Exception as e:
logger.debug(f"타오바오 자동매칭 스레드 실행 중 에러 : {e}")
logger.debug(f"타오바오 자동매칭 스레드 실행 중 에러 : {e}", exc_info=True)
def on_automatch_finished(self):
# automatch 작업 완료 후 처리
@ -829,11 +829,11 @@ class Ui_Dialog(QtWidgets.QDialog):
# self.timerLabel.setText(f"{minutes:02d}:{seconds:02d}")
def getMatchingUrlCount(self):
# 데이터베이스 연결 및 MatchingUrl 개수 조회
# 데이터베이스 연결 및 MatchingUrl 개수 조회
try:
conn = sqlite3.connect(self.db_name) # 데이터베이스 파일 이름을 self.db_name 변수에 저장
current_table = self.comboBox.currentText() # 현재 선택된 테이블 이름 가져오기
query = f"SELECT COUNT(*) FROM {current_table} WHERE MatchingUrl IS NOT NULL"
query = f'SELECT COUNT(*) FROM "{current_table}" WHERE MatchingUrl IS NOT NULL'
cursor = conn.cursor()
cursor.execute(query)
@ -841,7 +841,7 @@ class Ui_Dialog(QtWidgets.QDialog):
conn.close()
return count
except Exception as e:
logger.debug(f"Error: {e}")
logger.debug(f"Error: {e}", exc_info=True)
return 0 # 에러가 발생한 경우 0 반환
@ -884,7 +884,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.update_match_count()
def export_data(self):
def export_data_by_branch(self):
# 저장할 파일 위치와 이름 선택
today = datetime.now().strftime('%Y%m%d_%H%M')
default_filename = f"{today}_1.xlsx"
@ -892,9 +892,9 @@ class Ui_Dialog(QtWidgets.QDialog):
if file_name:
#self.save_to_excel(file_name)
self.save_to_excel_with_xlwings(self.db_name, file_name)
self.save_to_excel_with_xlwings_by_branch(self.db_name, file_name)
def export_data_by_auto(self):
def export_data_by_main(self):
# 저장할 파일 위치와 이름 선택
today = datetime.now().strftime('%Y%m%d_%H%M')
default_filename = f"{today}_1.xlsx"
@ -902,7 +902,7 @@ class Ui_Dialog(QtWidgets.QDialog):
if file_name:
#self.save_to_excel(file_name)
self.save_to_excel_with_xlwings_by_auto(self.db_name, file_name)
self.save_to_excel_with_xlwings_by_main(self.db_name, file_name)
@ -1031,36 +1031,47 @@ class Ui_Dialog(QtWidgets.QDialog):
logger.debug(f"파일 '{part_file_name}'에 데이터가 추가되었습니다.")
def save_to_excel_with_xlwings(self, db_name, file_name):
# 로그 다이얼로그 생성 및 표시
log_dialog = LogDialog()
log_dialog.show()
self.saved_files = []
logger.debug("엑셀 저장 로그기록 시작")
message = "엑셀 저장 로그기록 시작"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
def save_to_excel_with_xlwings_by_branch(self, db_name, file_name):
try:
# 로그 다이얼로그 생성 및 표시
log_dialog = LogDialog()
log_dialog.show()
self.saved_files = []
logger.debug("엑셀 저장 로그기록 시작")
message = "엑셀 저장 로그기록 시작"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
# 로그 설정
logger.debug("엑셀 저장 로그기록 파일 생성")
# 데이터베이스에서 필요한 데이터 로드
conn = sqlite3.connect(db_name)
query = "SELECT MatchingUrl, keyword, MatchingCat, delvFee, packingFee, plusFee, manuTag FROM NaverShopping WHERE MatchingUrl IS NOT NULL"
df = pd.read_sql_query(query, conn)
conn.close()
logger.debug("DB 읽기 완료")
message = "DB 읽기 완료"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
# 'manuTag' 필드에서 '오늘' 단어 제거
df['manuTag'] = df['manuTag'].apply(lambda x: ','.join([word for word in str(x).split(',') if '오늘' not in word.strip()]))
logger.debug("태그 필터링")
message = "태그 필터링"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
# Excel 애플리케이션을 백그라운드에서 실행
app = xw.App(visible=False)
logger.debug("xlwings 시작")
# 로그 설정
logger.debug("엑셀 저장 로그기록 파일 생성")
# 데이터베이스에서 필요한 데이터 로드
conn = sqlite3.connect(db_name)
query = "SELECT MatchingUrl, keyword, MatchingCat, delvFee, packingFee, plusFee, manuTag, merged_price FROM NaverShopping WHERE MatchingUrl IS NOT NULL"
query2 = "SELECT MatchingUrl, keyword, MatchingCat, delvFee, packingFee, plusFee, manuTag, price FROM NaverShopping WHERE MatchingUrl IS NOT NULL"
try:
df = pd.read_sql_query(query, conn)
except:
df = pd.read_sql_query(query2, conn)
conn.close()
logger.debug("DB 읽기 완료")
message = "DB 읽기 완료"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
# 'manuTag' 필드에서 '오늘' 단어 제거
df['manuTag'] = df['manuTag'].apply(lambda x: ','.join([word for word in str(x).split(',') if '오늘' not in word.strip()]))
logger.debug("태그 필터링")
message = "태그 필터링"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
# Excel 애플리케이션을 백그라운드에서 실행
app = xw.App(visible=False)
logger.debug("xlwings 시작")
except Exception as e:
logger.debug(e)
# 예외를 로그에 기록
logging.error(f"파일 저장 준비 중 예외 발생: {str(e)}", exc_info=True)
message = f"파일 저장 준비 중 예외 발생: {str(e)}"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
try:
# 50개 행씩 나누어 파일 저장
@ -1077,14 +1088,25 @@ class Ui_Dialog(QtWidgets.QDialog):
wb = xw.Book(file_name)
ws = wb.sheets['multi_ss']
final_delv = 0
# 데이터 삽입
for index, row in df_subset.iterrows():
if 'sourcingman' in self.db_name or 'copyman' in self.db_name:
final_price = math.ceil((row['price'])*0.98 / 100) * 100 # 2%가격을 낮춘 후 100원단위 올림
else:
# final_delv = row['delvFee'] + row['packingFee']
if not row['murged_price']:
final_price = row['plusFee']
final_price = row['murged_price']
row_num = 4 + (index % 50)
ws.range(f'B{row_num}').value = row['MatchingUrl']
ws.range(f'C{row_num}').value = row['keyword']
ws.range(f'G{row_num}').value = row['MatchingCat']
ws.range(f'E{row_num}').value = row['delvFee'] + row['packingFee']
ws.range(f'D{row_num}').value = row['plusFee']
ws.range(f'E{row_num}').value = final_delv
ws.range(f'D{row_num}').value = final_price
ws.range(f'F{row_num}').value = row['manuTag']
logger.debug(f"{index}번째 {row_num-3}엑셀데이터 기록")
# 저장 및 닫기
@ -1107,7 +1129,7 @@ class Ui_Dialog(QtWidgets.QDialog):
except Exception as e:
logger.debug(e)
# 예외를 로그에 기록
logging.error(f"파일 저장 중 예외 발생: {str(e)}")
logging.error(f"파일 저장 중 예외 발생: {str(e)}", exc_info=True)
message = f"파일 저장 중 예외 발생: {str(e)}"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
finally:
@ -1126,7 +1148,7 @@ class Ui_Dialog(QtWidgets.QDialog):
else:
logger.debug("저장 프로세스가 종료되었습니다.")
def save_to_excel_with_xlwings_by_auto(self, db_name, file_name):
def save_to_excel_with_xlwings_by_main(self, db_name, file_name):
# 로그 다이얼로그 생성 및 표시
log_dialog = LogDialog()
log_dialog.show()
@ -1214,11 +1236,11 @@ class Ui_Dialog(QtWidgets.QDialog):
time.sleep(1)
# 로그에 파일 저장 정보 추가
logger.debug(f"로그 '{part_file_name.log}'에 로그데이터가 추가되었습니다.")
logger.debug(f"로그 '{part_file_name}'에 로그데이터가 추가되었습니다.")
except Exception as e:
logger.debug(e)
# 예외를 로그에 기록
logging.error(f"파일 저장 중 예외 발생: {str(e)}")
logging.error(f"파일 저장 중 예외 발생: {str(e)}", exc_info=True)
message = f"파일 저장 중 예외 발생: {str(e)}"
log_dialog.add_log_message(message) # 로그 다이얼로그에 메시지 추가
finally:
@ -1250,7 +1272,7 @@ class Ui_Dialog(QtWidgets.QDialog):
def get_query_for_table(self, table_name):
queries = {
"Keywords": "SELECT keyword, base_category, MatchingUrl, MatchingCat, id FROM Keywords",
"NaverShopping": "SELECT keyword_id, keyword, delvFee, packingFee, plusFee, MatchingUrl, MatchingCat, productTitle, price, category1Name, category2Name, category3Name, category4Name, localImagePath, id, cat_code, tao_imageUrl FROM NaverShopping",
"NaverShopping": "SELECT keyword_id, keyword, delvFee, packingFee, plusFee, MatchingUrl, MatchingCat, productTitle, price, category1Name, category2Name, category3Name, category4Name, localImagePath, id, cat_code, tao_imageUrl, merged_price FROM NaverShopping",
# "Taobao": "SELECT keyword_id, item_name, price, imageSearchUrl, keywordSearchUrl, rank FROM Taobao",
"Taobao": "SELECT * FROM Taobao",
"SubKeywords": "SELECT keyword_id, relatedTags, id FROM SubKeywords",
@ -1361,7 +1383,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.addmargin_spbox.setValue(int(additional_margin)) # 올바른 방법으로 값을 설정
except Exception as e:
logger.debug(f"가격 오류 : {e}")
logger.debug(f"가격 오류 : {e}", exc_info=True)
try:
cat1 = index.sibling(index.row(), 9).data()
@ -1390,7 +1412,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.catbox4.setText(cat4)
self.catcodebox.setText(cat_code)
except Exception as e:
logger.debug(f"카테고리 오류 : {e}")
logger.debug(f"카테고리 오류 : {e}", exc_info=True)
# 카테고리 코드 박스가 비어있을 경우 붉은색으로 경고표시
self.check_and_set_color()
@ -1421,7 +1443,7 @@ class Ui_Dialog(QtWidgets.QDialog):
logger.debug(f"이미지 로드 실패: {localImagePath}")
except Exception as e:
logger.debug(f"이미지 클립보드 복사 오류: {e}")
logger.debug(f"이미지 클립보드 복사 오류: {e}", exc_info=True)
# 선택된 행의 ID 가져오기 (ID가 첫 번째 열에 있다고 가정)
self.selected_row_id = index.sibling(index.row(), 14).data()
@ -1555,10 +1577,10 @@ class Ui_Dialog(QtWidgets.QDialog):
#getattr(self, f'sel_itembox{i+1}2').setText(manuTags[i])
except sqlite3.OperationalError as e:
logger.debug(f"SQL 오류: {e}")
logger.debug(f"SQL 오류: {e}", exc_info=True)
QtWidgets.QMessageBox.warning(self, "오류", "DB에서 데이터를 가져오는 중 오류가 발생했습니다.")
except Exception as e:
logger.debug(f"일반 오류: {e}")
logger.debug(f"일반 오류: {e}", exc_info=True)
QtWidgets.QMessageBox.warning(self, "오류", "알 수 없는 오류가 발생했습니다.")
self.update_match_count()
@ -1685,7 +1707,7 @@ class Ui_Dialog(QtWidgets.QDialog):
logger.debug(f"Failed to download image: {url}")
return None
except Exception as e:
logger.debug(f"Error downloading image {url}: {e}")
logger.debug(f"Error downloading image {url}: {e}", exc_info=True)
return None
def load_images_by_keyword_id(self, keyword_id):
@ -2056,7 +2078,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.scraping_thread.finished.connect(self.start_image_save_thread) # 스크래핑 완료 후 이미지 저장 스레드 시작
self.scraping_thread.start()
except Exception as e:
logger.debug(f"에러발생 : {e}")
logger.debug(f"에러발생 : {e}", exc_info=True)
def click_image_save_btn(self):
# QMessageBox.information(self, "알림", "네이버 이미지 저장 시작!")
@ -2164,7 +2186,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.db_name = now.strftime('%Y-%m-%d-%H%M') + '_copyman' + '.db'
conn = sqlite3.connect(self.db_name)
# DB 생성 함수 호출 예시 (실제 구현 필요)
# DB 생성 함수 호출
create_db(self.db_name)
logger.debug("카피맨 DB생성 완료")
@ -2172,6 +2194,13 @@ class Ui_Dialog(QtWidgets.QDialog):
logger.debug("카피맨 데이터 : 카테고리', '가격', '상품명', '태그', '이미지URL' 읽기")
df = pd.read_excel(file_name, usecols=['카테고리', '가격', '상품명', '태그', '이미지URL'])
logger.debug("카피맨 엑셀파일 읽기 완료")
# '카테고리' 컬럼이 없거나 NaN인 경우 '카테고리1>카테고리2>카테고리3>카테고리4'로 대체
if '카테고리' not in df.columns or df['카테고리'].isnull().all():
df['카테고리'] = '카테고리1>카테고리2>카테고리3>카테고리4'
else:
df['카테고리'] = df['카테고리'].fillna('카테고리1>카테고리2>카테고리3>카테고리4')
# '카테고리' 데이터를 분리하고 필요한 만큼의 컬럼만 선택
categories = df['카테고리'].str.split(r'>|-', expand=True).fillna('')
@ -2473,6 +2502,10 @@ def send_exit_message():
if __name__ == "__main__":
# 프로그램 종료 시 호출될 함수 등록
atexit.register(restore_sleep_mode)
atexit.register(record_logout_time)
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
app = QApplication(sys.argv)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 130 KiB