Well, it took me about five hours to get this operational. But after a great amount of research and testing, I finally did it. In all of it's annoying glory, here it is:#
from turtle import *
import urllib2
import xml.etree.ElementTree as ET
from random import randint
import time
import math
import os
#Written by Eric DiGioachino (cpunation)
def GET_STOCKS(sym, n):
ida = []
for i in range(0,n):
ida.append(chr(randint(65,90)))
idb = "".join(ida)
idn = idb #yes this is needed, it makes sure that the join has been processed
def BD(data):
fo = open("stcks.xml", "w+")
fo.write(data)
fo.close()
tree = ET.parse("stcks.xml")
root = tree.getroot()
item = root.find('Change')
att = item.text
return att
urls = "http://dev.markitondemand.com/Api/v2/Quote/xml?symbol=" + sym + "&callback=" + idn
resp = urllib2.urlopen(urls, timeout = 1)
data = resp.read()
print BD(data)
return BD(data)
left(90)
j = 0
hideturtle()
while True:
time.sleep(30) #this limits time in between requests, it makes sure that the server doesn't spit you out for quick request times
penup()
goto(j,0)
inc = float(GET_STOCKS("AAPL", 8))
goto(j, (inc * 10))
pendown()
forward(10)
j += 1
os.remove("stcks.xml")