def QtDownMulti(codes): qcode = '' for i in range(0, len(codes)): qcode += sat_util.codeAddPrefix(codes[i]) + ',' durl = qurl + 'r=' + str(random.random()) + '&q=' + qcode if (debug): print(durl) s = sat_down.GetMultiRtPriceByURL(durl) if (debug): print(s, len(s)) return QtParseMulti(s)
def QtDownMulti(codes): qcode='' for i in range(0, len(codes)): qcode += sat_util.codeAddPrefix(codes[i]) +',' durl=qurl+'r='+str(random.random())+'&q='+qcode if (debug): print(durl) s=sat_down.GetMultiRtPriceByURL(durl) if (debug): print(s, len(s)) return QtParseMulti(s)
def yahooDown(code): code = sat_util.codeAddPrefix(code) durl = qurl + qrandomPrefix + str(random.random()) + qcodePrefix + code if (debug): print(durl) s = sat_down.GetRtPriceByURL(durl) if s == '': return False, None strGB = sat_util.ToGB(s) return yahooParseSingle(strGB)
def SinaDown(code): code=sat_util.codeAddPrefix(code) durl=qurl+qrandomPrefix+str(random.random())+qcodePrefix+code if (debug): print(durl) s = sat_down.GetRtPriceByURL(durl) if s == '': return False,None strGB=sat_util.ToGB(s) return SinaParseSingle(strGB)
def QtDown(code): code=sat_util.codeAddPrefix(code) durl=qurl+'r='+str(random.random())+'&q='+code #durl=qurl+code if (debug): print(durl) s = sat_down.GetRtPriceByURL(durl) if s == '': return False,None strGB=sat_util.ToGB(s) return QtParseSingle(strGB)
def QtDown(code): code = sat_util.codeAddPrefix(code) durl = qurl + 'r=' + str(random.random()) + '&q=' + code #durl=qurl+code if (debug): print(durl) s = sat_down.GetRtPriceByURL(durl) if s == '': return False, None strGB = sat_util.ToGB(s) return QtParseSingle(strGB)
def SinaDownHistory(code, dtEnd, dtStart, f): qcode=sat_util.codeAddPrefix(code) insCode=qcode[2:] yEnd = int(dtEnd.year) mEnd = int(dtEnd.month) dEnd = int(dtEnd.day) yStart=int(dtStart.year) mStart = int(dtStart.month) dStart = int(dtStart.day) qyEnd = '' qmEnd = '' qdEnd = '' qyStart = '' qmStart = '' qdStart = '' for i in range(yStart, yEnd+1): if i == yEnd and i == yStart: qmEnd = str(mEnd) qdEnd = str(dEnd) qmStart = str(mStart) qdStart = str(dStart) elif i == yEnd and i > yStart: qmEnd = str(mEnd) qdEnd = str(dEnd) qmStart = '01' qdStart = '01' elif i < yEnd and i > yStart: qmEnd = '12' qdEnd = '31' qmStart = '01' qdStart = '01' elif i < yEnd and i == yStart: qmEnd = '12' qdEnd = '31' qmStart = str(mStart) qdStart = str(dStart) else: print("date error, give up this query") break qyEnd = str(i) qyStart = qyEnd if len(qmEnd) < 2: qmEnd = '0'+qmEnd if len(qdEnd) < 2: qdEnd = '0' + qdEnd if len(qmStart) < 2: qmStart = '0'+qmStart if len(qdStart) < 2: qdStart = '0' + qdStart qDate = qdtEndPre+qyEnd+qmEnd+qdEnd+qdtStartPre+qyStart+qmStart+qdStart durl=qurlHis+qrandomPre+str(random.randint(0,10000))+qcodePre+qcode+qDate+qtype if (debug): print(durl) s = sat_down.GetMultiRtPriceByURL(durl) if s == None or s == '': #print("sn_down open url failed ", durl) continue wStr='' for i in range(0, len(s)): strUTF8=sat_util.ToUTF8(s[i]) slist=insCode+','+strUTF8 wStr += slist if wStr != '': f.writelines(wStr)