from
PyQt5.QtWidgets
import
*
from
PyQt5
import
QtCore, QtGui
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
from
bs4
import
BeautifulSoup as BS
import
requests
import
sys
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle(
"Python "
)
self
.setGeometry(
100
,
100
,
400
,
500
)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
push
=
QPushButton(
"Press"
,
self
)
push.setGeometry(
125
,
100
,
150
,
40
)
self
.label_total
=
QLabel(
"Total Cases "
,
self
)
self
.label_total.setGeometry(
100
,
200
,
200
,
40
)
self
.label_total.setAlignment(Qt.AlignCenter)
self
.label_total.setStyleSheet(
"border : 2px solid black;"
)
self
.label_reco
=
QLabel(
"Recovered Cases "
,
self
)
self
.label_reco.setGeometry(
100
,
250
,
200
,
40
)
self
.label_reco.setAlignment(Qt.AlignCenter)
self
.label_reco.setStyleSheet(
"border : 2px solid black;"
)
self
.label_death
=
QLabel(
"Total Deaths "
,
self
)
self
.label_death.setGeometry(
100
,
300
,
200
,
40
)
self
.label_death.setAlignment(Qt.AlignCenter)
self
.label_death.setStyleSheet(
"border : 2px solid black;"
)
push.clicked.connect(
self
.get_cases)
def
get_cases(
self
):
soup
=
BS(data.text,
'html.parser'
)
total
=
soup.find(
"div"
,
class_
=
"maincounter-number"
).text
total
=
total[
1
:
len
(total)
-
2
]
other
=
soup.find_all(
"span"
,
class_
=
"number-table"
)
recovered
=
other[
2
].text
deaths
=
other[
3
].text
deaths
=
deaths[
1
:]
self
.label_total.setText(
"Total Cases : "
+
total)
self
.label_reco.setText(
"Recovered Cases : "
+
recovered)
self
.label_death.setText(
"Total Deaths : "
+
deaths)
App
=
QApplication(sys.argv)
window
=
Window()
window.show()
sys.exit(App.
exec
())