-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
sss_indices.py
49 lines (42 loc) · 2.34 KB
/
sss_indices.py
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
#############################################################################
#
# Version 0.1.61 - Author: Asaf Ravid <[email protected]>
#
# Stock Screener and Scanner - based on yfinance
# Copyright (C) 2021 Asaf Ravid
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
# Prototype for downloading the latest TASE indices directly.
# TODO: ASAFR: Add output directly to CSV (currently printed on screen)
import urllib3
import certifi
def update_tase_indices():
url_tase_indices = 'https://info.tase.co.il/_layouts/Tase/ManagementPages/Export.aspx?sn=none&action=1&SubAction=0&GridId=33&CurGuid={85603D39-703A-4619-97D9-CE9F16E27615}&ExportType=3'
http = urllib3.PoolManager(ca_certs=certifi.where())
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
req = http.request('GET', url_tase_indices, headers=headers)
data_tase = req.data.decode('utf-8')
data_tase_no_extra_lines = "\n".join(data_tase.splitlines())
f = open('Indices/Data_TASE.csv','w')
f.write(data_tase_no_extra_lines)
f.close()
url_tase_dual_indices = 'https://info.tase.co.il/_layouts/Tase/ManagementPages/Export.aspx?sn=none&action=2&SubAction=0&dualTab=1&GridId=32&CurGuid={85603D39-703A-4619-97D9-CE9F16E27615}&ExportType=3'
req = http.request('GET', url_tase_dual_indices, headers=headers)
data_tase = req.data.decode('utf-8')
data_tase_no_extra_lines = "\n".join(data_tase.splitlines())
f = open('Indices/Data_Duals_TASE.csv','w')
f.write(data_tase_no_extra_lines)
f.close()