Guest User

scrape_ui.py

a guest
Dec 26th, 2022
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. import controller
  2. from PyQt5 import QtCore, QtGui, QtWidgets
  3.  
  4. class Ui_MainWindow(object):
  5. def setupUi(self, MainWindow):
  6. MainWindow.setObjectName("MainWindow")
  7. MainWindow.resize(490, 500)
  8. self.centralwidget = QtWidgets.QWidget(MainWindow)
  9. self.centralwidget.setObjectName("centralwidget")
  10. self.tell_keyword = QtWidgets.QLabel(self.centralwidget)
  11. self.tell_keyword.setGeometry(QtCore.QRect(30, 20, 167, 26))
  12. self.tell_keyword.setMaximumSize(QtCore.QSize(191, 16777215))
  13. font = QtGui.QFont()
  14. font.setFamily("Taipei Sans TC Beta")
  15. font.setPointSize(14)
  16. font.setBold(False)
  17. font.setWeight(50)
  18. self.tell_keyword.setFont(font)
  19. self.tell_keyword.setObjectName("tell_keyword")
  20. self.tell_pages = QtWidgets.QLabel(self.centralwidget)
  21. self.tell_pages.setGeometry(QtCore.QRect(30, 90, 148, 26))
  22. self.tell_pages.setMaximumSize(QtCore.QSize(191, 16777215))
  23. font = QtGui.QFont()
  24. font.setFamily("Taipei Sans TC Beta")
  25. font.setPointSize(14)
  26. font.setBold(False)
  27. font.setWeight(50)
  28. self.tell_pages.setFont(font)
  29. self.tell_pages.setObjectName("tell_pages")
  30. self.start_button = QtWidgets.QPushButton(self.centralwidget)
  31. self.start_button.clicked.connect(self.onButtonClick)
  32. self.start_button.setGeometry(QtCore.QRect(30, 238, 431, 71))
  33. font = QtGui.QFont()
  34. font.setFamily("Taipei Sans TC Beta")
  35. font.setPointSize(20)
  36. font.setBold(True)
  37. font.setWeight(75)
  38. self.start_button.setFont(font)
  39. self.start_button.setObjectName("start_button")
  40. self.state_table = QtWidgets.QTextBrowser(self.centralwidget)
  41. self.state_table.setGeometry(QtCore.QRect(30, 320, 431, 131))
  42. font = QtGui.QFont()
  43. font.setFamily("有愛ウォークラフト角ゴシック CN")
  44. font.setPointSize(11)
  45. self.state_table.setFont(font)
  46. self.state_table.setObjectName("state_table")
  47. self.keyword_input = QtWidgets.QLineEdit(self.centralwidget)
  48. self.keyword_input.setGeometry(QtCore.QRect(30, 50, 431, 31))
  49. font = QtGui.QFont()
  50. font.setFamily("有愛ウォークラフト角ゴシック CN")
  51. font.setPointSize(11)
  52. self.keyword_input.setFont(font)
  53. self.keyword_input.setText("")
  54. self.keyword_input.setObjectName("keyword_input")
  55. self.pages_input = QtWidgets.QLineEdit(self.centralwidget)
  56. self.pages_input.setGeometry(QtCore.QRect(30, 120, 431, 31))
  57. font = QtGui.QFont()
  58. font.setFamily("有愛ウォークラフト角ゴシック CN")
  59. font.setPointSize(11)
  60. self.pages_input.setFont(font)
  61. self.pages_input.setText("")
  62. self.pages_input.setObjectName("pages_input")
  63. self.type_shopee_button = QtWidgets.QPushButton(self.centralwidget)
  64. self.type_shopee_button.setCheckable(True)
  65. self.type_shopee_button.setGeometry(QtCore.QRect(30, 160, 211, 71))
  66. font = QtGui.QFont()
  67. font.setFamily("Taipei Sans TC Beta")
  68. font.setPointSize(20)
  69. font.setBold(True)
  70. font.setWeight(75)
  71. font.setKerning(True)
  72. self.type_shopee_button.setFont(font)
  73. self.type_shopee_button.setObjectName("type_shopee_button")
  74. self.type_ruten_button = QtWidgets.QPushButton(self.centralwidget)
  75. self.type_ruten_button.setCheckable(True)
  76. self.type_ruten_button.setGeometry(QtCore.QRect(250, 160, 211, 71))
  77. font = QtGui.QFont()
  78. font.setFamily("Taipei Sans TC Beta")
  79. font.setPointSize(20)
  80. font.setBold(True)
  81. font.setWeight(75)
  82. font.setKerning(True)
  83. self.type_ruten_button.setFont(font)
  84. self.type_ruten_button.setObjectName("type_ruten_button")
  85. self.start_button.raise_()
  86. self.tell_keyword.raise_()
  87. self.tell_pages.raise_()
  88. self.state_table.raise_()
  89. self.keyword_input.raise_()
  90. self.pages_input.raise_()
  91. self.type_shopee_button.raise_()
  92. self.type_ruten_button.raise_()
  93. MainWindow.setCentralWidget(self.centralwidget)
  94. self.menubar = QtWidgets.QMenuBar(MainWindow)
  95. self.menubar.setGeometry(QtCore.QRect(0, 0, 490, 21))
  96. self.menubar.setObjectName("menubar")
  97. MainWindow.setMenuBar(self.menubar)
  98. self.statusbar = QtWidgets.QStatusBar(MainWindow)
  99. self.statusbar.setObjectName("statusbar")
  100. MainWindow.setStatusBar(self.statusbar)
  101.  
  102. self.retranslateUi(MainWindow)
  103. QtCore.QMetaObject.connectSlotsByName(MainWindow)
  104.  
  105. def retranslateUi(self, MainWindow):
  106. _translate = QtCore.QCoreApplication.translate
  107. MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
  108. self.tell_keyword.setText(_translate("MainWindow", "請輸入商品關鍵字:"))
  109. self.tell_pages.setText(_translate("MainWindow", "請輸入搜尋頁數:"))
  110. self.start_button.setText(_translate("MainWindow", "開 始"))
  111. self.type_shopee_button.setText(_translate("MainWindow", "蝦 皮"))
  112. self.type_ruten_button.setText(_translate("MainWindow", "露天"))
  113.  
  114. def onButtonClick(self):
  115. product_keyword = self.keyword_input.text()
  116. product_pages = self.pages_input.text()
  117.  
  118. if self.type_shopee_button.isChecked():
  119. self.disply_text('開始執行蝦皮爬蟲1')
  120. controller.controller(product_keyword, product_pages, 'Shopee')
  121. self.disply_text('開始執行蝦皮爬蟲2')
  122.  
  123. if self.type_ruten_button.isChecked():
  124. self.disply_text('開始執行露天爬蟲')
  125. controller.controller(product_keyword, product_pages, 'Ruten')
  126.  
  127. def disply_text(self, text):
  128. print(text)
  129. self.state_table.append(text)
  130. self.cursot = self.state_table.textCursor()
  131. self.state_table.moveCursor(self.cursot.End)
  132. QtWidgets.QApplication.processEvents()
  133.  
  134. if __name__ == "__main__":
  135. import sys
  136. app = QtWidgets.QApplication(sys.argv)
  137. MainWindow = QtWidgets.QMainWindow()
  138. ui = Ui_MainWindow()
  139. ui.setupUi(MainWindow)
  140. MainWindow.show()
  141. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment