net, rnc = 25002, 0 import urllib ccc=range(30001,40001,10) lll=(6201,6202) # список лаков. a, i = '000E00000000000000000000000000001B0000000000000000000000030000', 0 file = open("scan_6000-6099.csv","w") try: for lac in lll: for cid in ccc: b = hex(rnc*65536+cid)[2:].zfill(8) + hex(lac)[2:].zfill(8) c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8) string = (a + b + c + 'FFFFFFFF00000000').decode('hex') data = urllib.urlopen('http://www.google.com/glm/mmap',string) r = data.read().encode('hex') file.write('%d; %d;' % (cid, lac)) if len(r) > 14 and int(r[22:23],16)==0 : x, y, i = float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000, i+1 if x > 53 and x < 57 and y > 35 and y < 41 : print cid, '[', lac, ']', '-', x, y file.write('%f; %f; %d\n' % (x, y, 1)) file.flush() else : file.write('%d; %d; %d\n' % (0, 0, 0)) file.flush() else : file.write('%d; %d; %d\n' % (0, 0, 0)) file.flush() except: print 'connect error' file.close() |