Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
kdrkdrkdr committed Apr 11, 2021
1 parent 8560d66 commit d642f26
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 1,270 deletions.
Binary file removed 89/chromedriver.exe
Binary file not shown.
48 changes: 33 additions & 15 deletions UI_MAIN.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,15 @@ def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(268, 167)
MainWindow.resize(272, 242)
MainWindow.setMinimumSize(QSize(268, 167))
MainWindow.setMaximumSize(QSize(268, 174))
MainWindow.setMaximumSize(QSize(16777215, 16777215))
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.trans_time = QLabel(self.centralwidget)
self.trans_time.setObjectName(u"trans_time")
self.trans_time.setGeometry(QRect(24, 117, 61, 31))
self.sec = QLabel(self.centralwidget)
self.sec.setObjectName(u"sec")
self.sec.setGeometry(QRect(83, 117, 91, 31))
self.dev_info = QLabel(self.centralwidget)
self.dev_info.setObjectName(u"dev_info")
self.dev_info.setGeometry(QRect(183, 117, 71, 31))
self.btnFrame = QFrame(self.centralwidget)
self.btnFrame.setObjectName(u"btnFrame")
self.btnFrame.setGeometry(QRect(9, 10, 251, 101))
self.btnFrame.setFrameShape(QFrame.StyledPanel)
self.btnFrame.setFrameShape(QFrame.Box)
self.btnFrame.setFrameShadow(QFrame.Raised)
self.go_dev_page = QPushButton(self.btnFrame)
self.go_dev_page.setObjectName(u"go_dev_page")
Expand All @@ -53,6 +44,31 @@ def setupUi(self, MainWindow):
self.show_trans_btn.setObjectName(u"show_trans_btn")
self.show_trans_btn.setGeometry(QRect(13, 10, 131, 31))
self.show_trans_btn.setFont(font)
self.timeFrame = QFrame(self.centralwidget)
self.timeFrame.setObjectName(u"timeFrame")
self.timeFrame.setGeometry(QRect(9, 120, 251, 31))
self.timeFrame.setFrameShape(QFrame.Box)
self.timeFrame.setFrameShadow(QFrame.Raised)
self.sec = QLabel(self.timeFrame)
self.sec.setObjectName(u"sec")
self.sec.setGeometry(QRect(83, 1, 81, 31))
self.trans_time = QLabel(self.timeFrame)
self.trans_time.setObjectName(u"trans_time")
self.trans_time.setGeometry(QRect(13, 1, 61, 31))
self.frame = QFrame(self.centralwidget)
self.frame.setObjectName(u"frame")
self.frame.setGeometry(QRect(9, 160, 251, 31))
self.frame.setFrameShape(QFrame.Box)
self.frame.setFrameShadow(QFrame.Raised)
self.show_status = QLabel(self.frame)
self.show_status.setObjectName(u"show_status")
self.show_status.setGeometry(QRect(50, 8, 191, 16))
self.status_lbl = QLabel(self.frame)
self.status_lbl.setObjectName(u"status_lbl")
self.status_lbl.setGeometry(QRect(13, 8, 31, 16))
self.dev_info = QLabel(self.centralwidget)
self.dev_info.setObjectName(u"dev_info")
self.dev_info.setGeometry(QRect(13, 202, 251, 21))
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
Expand All @@ -65,12 +81,14 @@ def setupUi(self, MainWindow):

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Ehnd \uc6f9 \ubc88\uc5ed", None))
self.trans_time.setText(QCoreApplication.translate("MainWindow", u"\ubc88\uc5ed \uc2dc\uac04:", None))
self.sec.setText("")
self.dev_info.setText(QCoreApplication.translate("MainWindow", u"\uc81c\uc791\uc790: kdr", None))
self.go_dev_page.setText(QCoreApplication.translate("MainWindow", u"\uc81c\uc791\uc790\n"
"\ud648\ud398\uc774\uc9c0", None))
self.show_ori_btn.setText(QCoreApplication.translate("MainWindow", u"\uc6d0\ubcf8 \ubcf4\uae30", None))
self.show_trans_btn.setText(QCoreApplication.translate("MainWindow", u"\ubc88\uc5ed\ubcf8 \ubcf4\uae30", None))
self.sec.setText("")
self.trans_time.setText(QCoreApplication.translate("MainWindow", u"\ubc88\uc5ed \uc2dc\uac04:", None))
self.show_status.setText("")
self.status_lbl.setText(QCoreApplication.translate("MainWindow", u"\uc0c1\ud0dc: ", None))
self.dev_info.setText(QCoreApplication.translate("MainWindow", u"\uc81c\uc791\uc790: kdr \ub9c8\uc9c0\ub9c9 \uc5c5\ub370\uc774\ud2b8: 210411", None))
# retranslateUi

146 changes: 102 additions & 44 deletions UI_MAIN.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>268</width>
<height>167</height>
<width>272</width>
<height>242</height>
</rect>
</property>
<property name="minimumSize">
Expand All @@ -21,53 +21,14 @@
</property>
<property name="maximumSize">
<size>
<width>268</width>
<height>174</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Ehnd 웹 번역</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="trans_time">
<property name="geometry">
<rect>
<x>24</x>
<y>117</y>
<width>61</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>번역 시간:</string>
</property>
</widget>
<widget class="QLabel" name="sec">
<property name="geometry">
<rect>
<x>83</x>
<y>117</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="dev_info">
<property name="geometry">
<rect>
<x>183</x>
<y>117</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>제작자: kdr</string>
</property>
</widget>
<widget class="QFrame" name="btnFrame">
<property name="geometry">
<rect>
Expand All @@ -78,7 +39,7 @@
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
Expand Down Expand Up @@ -140,6 +101,103 @@
</property>
</widget>
</widget>
<widget class="QFrame" name="timeFrame">
<property name="geometry">
<rect>
<x>9</x>
<y>120</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="sec">
<property name="geometry">
<rect>
<x>83</x>
<y>1</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="trans_time">
<property name="geometry">
<rect>
<x>13</x>
<y>1</y>
<width>61</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>번역 시간:</string>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>9</x>
<y>160</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="show_status">
<property name="geometry">
<rect>
<x>50</x>
<y>8</y>
<width>191</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="status_lbl">
<property name="geometry">
<rect>
<x>13</x>
<y>8</y>
<width>31</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>상태: </string>
</property>
</widget>
</widget>
<widget class="QLabel" name="dev_info">
<property name="geometry">
<rect>
<x>13</x>
<y>202</y>
<width>251</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>제작자: kdr 마지막 업데이트: 210411</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
Expand Down
Binary file modified __pycache__/UI_MAIN.cpython-37.pyc
Binary file not shown.
82 changes: 62 additions & 20 deletions _feature_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,78 @@

# chromedriver_autoinstaller.install('./utils/')

options = webdriver.ChromeOptions()
options.add_argument("disable-gpu")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_experimental_option('excludeSwitches', ['enable-logging'])



driver = webdriver.Chrome(executable_path='./89/chromedriver.exe',options=options)
driver.get('https://ncode.syosetu.com/n1031gv/2/')
sleep(1)

def runTrans(i):
print(i)
# try:
# if i.is_displayed():

# inner = i.get_attribute('innerHTML')
# outer = i.get_attribute('outerHTML')

# if bool(len(re.sub(r'\s+', '', inner))):
# p_html = PrettifyHtml(outer).split('\n')

a = driver.find_elements_by_xpath('.//*[normalize-space(text())]')
# modified_html = []
# for ih in p_html:

# if re.sub(r'\s+', '', ih).startswith('<'):
# modified_html.append(ih)
# else:
# modified_html.append(t_j2k(ih))


# ih_elements = ''.join(modified_html)

# nDict = {}
# nDict[i] = ih_elements

entire_text = []
element_type = []
# except:
# pass

for i in a:
if i.is_displayed():

inner = i.get_attribute('innerHTML')
outer = i.get_attribute('outerHTML')
# return nDict

if BeautifulSoup(inner, 'html.parser').text:
p_html = PrettifyHtml(outer).split('\n')

et = [ih for ih in p_html if not re.sub(r'\s+', '', ih).startswith('<')]
entire_text.extend(et)
element_type.append(i)

from multiprocessing import Pool, freeze_support
if __name__ == "__main__":
freeze_support()

options = webdriver.ChromeOptions()
options.add_argument("disable-gpu")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver = webdriver.Chrome(executable_path='./89/chromedriver.exe',options=options)
driver.get('https://syosetu.org/novel/254978/')
sleep(1)



a = driver.find_elements_by_xpath('.//*[normalize-space(text())]')
pprint(a)
print(type(a))

driver.close()

p = Pool(len(a))
pprint(p.map(runTrans, a))




# for k, v in ele_dict.items():
# try:
# driver.execute_script("arguments[0].outerHTML = arguments[1]", k, v)
# except:
# print(v)


# b = t_j2k('##########'.join())


Loading

0 comments on commit d642f26

Please sign in to comment.