-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindices.py
More file actions
49 lines (41 loc) · 1.76 KB
/
Copy pathindices.py
File metadata and controls
49 lines (41 loc) · 1.76 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
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QTimer
import requests
from bs4 import BeautifulSoup
from error_messages import *
class RealTimeLabel(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
def update_indices(self):
print("Updating Quotes...")
self.loading.setText("Loading")
Chart.loading(self)
# DOW update
url = "https://finance.yahoo.com/quote/%5EDJI?p=%5EDJI"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
price = soup.find_all('div', {'class': 'My(6px) Pos(r) smartphone_Mt(6px)'})[0].find('span').text
print(price)
self.btn_DOW_quote.setText(price)
# NASDAQ update
url = "https://finance.yahoo.com/quote/%5EIXIC?p=%5EIXIC"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
price = soup.find_all('div', {'class': 'My(6px) Pos(r) smartphone_Mt(6px)'})[0].find('span').text
print(price)
self.btn_NAS_quote.setText(price)
# S&P 500 update
url = "https://finance.yahoo.com/quote/%5EGSPC?p=%5EGSPC"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
price = soup.find_all('div', {'class': 'My(6px) Pos(r) smartphone_Mt(6px)'})[0].find('span').text
print(price)
self.btn_SP_quote.setText(price)
# Russell 2000 update
url = "https://finance.yahoo.com/quote/%5ERUT?p=%5ERUT"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
price = soup.find_all('div', {'class': 'My(6px) Pos(r) smartphone_Mt(6px)'})[0].find('span').text
self.btn_RUSS_quote.setText(price)
self.loading.setText("")