def post(data): url = 'http://ytbus.jiaodong.cn:4990/BusPosition.asmx/GetBusLineStatus' res = session.post(url,data[2]) position = res.text.split('>')[2].split('<')[0] jsondata = json.loads(position) for i in range(len(jsondata)): x = float(jsondata[i]['GPSX']) y = float(jsondata[i]['GPSY']) pai = jsondata[i].values()[3] a,b = getbaiduxyz(x,y) #print a,b dis = circle(a,b) if dis < 2000 and b > 37.466839 and a > 121.444287: msg = '%s %s路 距离上车点 %f 米 可以上车' % (pai,data[0],dis) sendweixin(msg) #if data[1] == 0: print '%s %s路 距离上车点 %f 米 可以上车' % (pai,data[0],dis)
def post(data): url = 'http://ytbus.jiaodong.cn:4990/BusPosition.asmx/GetBusLineStatus' res = session.post(url,data[2]) position = res.text.split('>')[2].split('<')[0] jsondata = json.loads(position) for i in range(len(jsondata)): # print jsondata[i] x = float(jsondata[i]['GPSX']) y = float(jsondata[i]['GPSY']) pai = jsondata[i].values()[3] station = jsondata[i].values()[2] ID = jsondata[i].values()[4] a,b = getbaiduxyz(x,y) line = data[0] # print pai,a,b,ID,station,line paiu = pai.encode('utf-8') IDu = ID.encode('utf-8') stationu = station.encode('utf-8') # print type(paiu),type(stationu),type(IDu) t = time.strftime(ISOTIMEFORMAT,time.localtime(time.time())) insert(pai,a,b,ID,station,line,t) dis = circle(a,b) if dis < 2000 and b > 37.466839 and a > 121.444287: msg = '%s %s路 距离上车点 %f 米 可以上车' % (pai,data[0],dis)