from
bs4
import
BeautifulSoup as BS
import
requests
from
PyQt5.QtWidgets
import
*
from
PyQt5
import
QtCore, QtGui
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
import
sys
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle("PyQt5 Bit Coin ")
self
.setGeometry(
100
,
100
,
400
,
600
)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
self
.label
=
QLabel("
/
/
BIT
-
COIN
/
/
",
self
)
self
.label.setGeometry(
50
,
150
,
300
,
50
)
self
.label.setAlignment(Qt.AlignCenter)
self
.label.setFont(QFont(
'Times'
,
15
))
self
.label.setStyleSheet("border :
3px
solid black;")
button
=
QPushButton("Show price",
self
)
button.setGeometry(
150
,
300
,
100
,
40
)
button.clicked.connect(
self
.show_price)
button.setToolTip("Press to get Bit Coin Price")
def
show_price(
self
):
url
=
"https:
/
/
www.google.com
/
search?q
=
bitcoin
+
price"
data
=
requests.get(url)
soup
=
BS(data.text,
'html.parser'
)
ans
=
soup.find("div",
class_
=
"BNeawe iBp4i AP7Wnd").text
self
.label.setText(ans)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())