Skip to content

Commit 2305d96

Browse files
committed
- Page Explorer Bug Fix
1 parent e99f1e1 commit 2305d96

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

main.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SearchThread(QThread):
3131
ThreadMessageEvent = pyqtSignal(str) # 사용자 정의 시그널
3232
QLabelWidgetUpdate = pyqtSignal(str) # 라벨 위젯 업데이트
3333
QTableWidgetUpdate = pyqtSignal(list) # 테이블 위젯 업데이트
34-
QTableWidgetSetSort = pyqtSignal(bool) # 테이블 위젯 컬럼 정렬 기능 ON/OFF
34+
QTableWidgetSetSort = pyqtSignal(bool) # 테이블 위젯 컬럼 정렬 기능 ON/OFF
3535

3636
# 메인폼에서 상속받기
3737
def __init__(self, parent): # parent는 WindowClass에서 전달하는 self이다.(WidnowClass의 인스턴스)
@@ -52,7 +52,7 @@ def run(self):
5252

5353
idx = 0
5454

55-
#데이터 삽입 중엔 Column 정렬기능을 OFF 하자. (ON 할 경우 다운될 수도 있음.)
55+
# 데이터 삽입 중엔 Column 정렬기능을 OFF 하자. (ON 할 경우 다운될 수도 있음.)
5656
self.QTableWidgetSetSort.emit(False)
5757
while True:
5858
if not running:
@@ -97,17 +97,29 @@ def stop(self):
9797
self.wait(3000)
9898

9999
# 모듈화에 문제가 생겨서 우선 하드 코딩
100+
101+
100102
def resource_path(relative_path):
101-
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
103+
base_path = getattr(sys, '_MEIPASS', os.path.dirname(
104+
os.path.abspath(__file__)))
102105
return os.path.join(base_path, relative_path)
103106

104107

105108
# Main UI Load
106109
main_ui = resource_path('main.ui')
107-
Ui_MainWindow = uic.loadUiType(main_ui)[0] # ui 가져오기
110+
Ui_MainWindow = uic.loadUiType(main_ui)[0] # UI 가져오기
108111

109112

110113
class Main(QMainWindow, Ui_MainWindow):
114+
# 타입 힌트 (IDE 자동 완성 지원을 위해)
115+
articleView: QTableWidget
116+
txt_repeat: QLineEdit
117+
txt_id: QLineEdit
118+
txt_keyword: QLineEdit
119+
btn_search: QPushButton
120+
comboBox: QComboBox
121+
txt_status: QLabel
122+
111123
def __init__(self):
112124
super().__init__()
113125
self.setupUi(self)
@@ -163,7 +175,6 @@ def setTableWidget(self):
163175
self.articleView.setColumnWidth(0, 60) # 글 번호
164176
self.articleView.setColumnWidth(1, 430) # 제목
165177
self.articleView.setColumnWidth(2, 50) # 댓글수
166-
167178
self.articleView.setColumnWidth(3, 100) # 글쓴이
168179
self.articleView.setColumnWidth(4, 60) # 작성일
169180
self.articleView.setColumnWidth(5, 40) # 조회
@@ -194,7 +205,6 @@ def search(self): # 글검색
194205
self.thread.terminate()
195206
self.thread.stop() # 쓰레드 종료
196207

197-
198208
if self.txt_id.text() != '' and self.txt_keyword.text() != '' and self.txt_repeat.text() != '':
199209
running = True
200210
self.articleView.setRowCount(0) # 글 초기화
@@ -293,8 +303,6 @@ def on_finished(self):
293303
pass
294304

295305

296-
297-
298306
app = QApplication([])
299307
main = Main()
300308
QApplication.processEvents()

module/article_parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ def page_explorer(self, keyword, s_type, search_pos=''):
130130
else:
131131
page['end'] = page_box[-2].text.strip()
132132

133-
if page['end'] == '이전검색':
133+
if '이전' in page['end']:
134134
page['end'] = 1
135-
page['end'] = int(page['end'])
135+
else:
136+
page['end'] = int(page['end'])
136137

137138
# next_pos 구하기 (다음 페이지 검색 위치)
138139
next_pos = soup.select('a.search_next')

0 commit comments

Comments
 (0)