mirror of
https://github.com/andrewkdinh/fund-indicators.git
synced 2024-11-21 21:14:20 -08:00
Update main.py
This commit is contained in:
parent
43736652ff
commit
7986f2c6c1
47
main.py
47
main.py
@ -4,21 +4,50 @@
|
|||||||
# Description: Get, parse, and interpret JSON files from IEX
|
# Description: Get, parse, and interpret JSON files from IEX
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import re
|
import re
|
||||||
import os
|
#import os, errno
|
||||||
|
import json
|
||||||
|
|
||||||
|
file_path = "tmp/data.txt"
|
||||||
|
# directory = os.path.dirname(file_path)
|
||||||
|
|
||||||
url = urllib.request.urlopen("https://api.iextrading.com/1.0/stock/aapl/chart")
|
url = urllib.request.urlopen("https://api.iextrading.com/1.0/stock/aapl/chart")
|
||||||
print("url =", url)
|
#print("url =", url)
|
||||||
html = url.read() # this is not a string, must convert it for findall()
|
html = url.read() # this is not a string, must convert it for findall()
|
||||||
# print("-----------------------------------------------")
|
|
||||||
# print("the html =", html)
|
# print("the html =", html)
|
||||||
|
|
||||||
if not os.path.exists(temporary):
|
myFile = open('data.json','r')
|
||||||
os.makedirs(temporary)
|
data = myFile.read()
|
||||||
|
|
||||||
myFile = open('temporary/data.txt','r')
|
json_string = json.dumps(data)
|
||||||
listOfLines = myFile.readlines()
|
print("json string:", data)
|
||||||
print("fileAsList:\n",listOfLines)
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
myFile =open(file_path,'w')
|
||||||
|
myFile.write(str(html))
|
||||||
|
myFile.close()
|
||||||
|
|
||||||
|
|
||||||
|
# Create tmp folder
|
||||||
|
try:
|
||||||
|
os.makedirs(directory)
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != errno.EEXIST:
|
||||||
|
raise
|
||||||
|
|
||||||
|
myFile = open(file_path,'r')
|
||||||
|
listOfLines = myFile.read().split('}')
|
||||||
|
#print("fileAsList:\n",listOfLines)
|
||||||
|
|
||||||
|
print(listOfLines[0],"\n")
|
||||||
|
print(listOfLines[1])
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
for j in range(0,len(listOfLines),1):
|
||||||
|
aLine = listOfLines[j]
|
||||||
|
#print(aLine)
|
||||||
|
lineData = aLine.split()
|
||||||
|
#print(lineData)
|
||||||
|
'''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
url = urllib.request.urlopen("http://www.gavilan.edu/staff/dir.php")
|
url = urllib.request.urlopen("http://www.gavilan.edu/staff/dir.php")
|
||||||
@ -45,4 +74,4 @@ for line in listOfLines:
|
|||||||
if match:
|
if match:
|
||||||
print(line)
|
print(line)
|
||||||
myFile.close()
|
myFile.close()
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user