-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkyScanner.py
More file actions
69 lines (50 loc) · 1.72 KB
/
Copy pathSkyScanner.py
File metadata and controls
69 lines (50 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Import Packages
import sys
from PyQt5 import QtWidgets as qtw
from PyQt5 import QtCore as qtc
from PyQt5 import QtGui as qtg
# Import Modules
from UI.Main_Window_UI import Ui_Form
from Crawler.crawler import Crawler
from Crawler.DB import DB
from UI.Table_view import Table_view
# URL of the webpage that we are scraping information from
BASE_URL = "https://www.esky.bg/oferti/co/bg/0/0/balgariya"
class Main_Window(qtw.QMainWindow, Ui_Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Ui_Form.__init__(self)
self.setupUi(self)
# Set Title and Icon
self.setWindowTitle("SkyScanner")
self.setWindowIcon(qtg.QIcon("./assets/Images/img.png"))
# Set fixed window size
self.setFixedSize(786, 654)
# Make click connections
self.btnRunCrawler.clicked.connect(self.onBtnRunCrawlerClick)
self.btnShowData.clicked.connect(self.onBtnShowDataClick)
self.show()
@qtc.pyqtSlot(bool)
def onBtnRunCrawlerClick(self):
# Scrape through the website
crawler = Crawler(BASE_URL)
crawler.start()
crawler_info = crawler.info
crawler.stop()
# Delete old table and make new with new data
self.db = DB()
self.db.remove_table()
self.db.create_table()
# Insert information into db
self.db.intert_rows(offers=crawler_info)
# Open Table View
self.onBtnShowDataClick()
self.close()
@qtc.pyqtSlot(bool)
def onBtnShowDataClick(self):
self.table_view = Table_view()
self.table_view.show()
if __name__ == "__main__":
app = qtw.QApplication(sys.argv)
window = Main_Window()
sys.exit(app.exec())