Google maps для Symbian, база данных Cell ID в GoogleNetmonitor GSM/UMTS: от телефонов до измерительных комплексов

Ответить
Netlog
Известный нетмониторщик
Сообщения: 469
Зарегистрирован: Пн, 02-02-2004, 21:46
Откуда: Ростов на Дону
Нетмонитор: Siemens S35
Контактная информация:

Сообщение Netlog »

McMaster, а что собственно нужно от скрипта?
Пардон, пару дней был без инета.
Тут то уже каких только не было примеров, надёргать кусков из разных - можно собрать все мыслимые варианты.
kazaros писал(а):здравствуйте) поставил себе и питон и мск, московский мегафон вытаскивают из гугла как положено, а вводил сид и лак мтс и мегафон питера...нет данных...
Конкретные примеры приводи, а так, на словах, ничего не понятно.
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

Netlog писал(а):а что собственно нужно от скрипта?
Пардон, пару дней был без инета.
нужен скриптик с прокси для скана гугла с записью в wpt, с возможностью перебора цид и лак, возможность у цид резные варианты перебора :)
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

а под какую версию питона пишете? версии 2 и 3 различаются :roll:
указывайте под какую версию :)
вот вроде надёргал

Код: Выделить всё

# -*- coding: cp1251 -*- 
operatorid = 01 
countrycode = 250 
a = '000E00000000000000000000000000001B0000000000000000000000030000' 
net = countrycode*100+operatorid 
i, count_error = 0,0 

import urllib2,sys,datetime 
#proxy = "92.207.45.14:8080" 
#proxy = "127.0.0.1:3128" 
#proxy = urllib2.ProxyHandler({"http" : proxy}) 
#opener = urllib2.build_opener(proxy) 
#urllib2.install_opener(opener)

now = datetime.datetime.now() 
now_s = str(now.year).zfill(4) + "-" + str(now.month).zfill(2) + "-" + str(now.day).zfill(2) + "_" + str(now.hour).zfill(2) + "-" + str(now.minute).zfill(2) + "-" + str(now.second).zfill(2) + ".csv" 
file = open(now_s,"w") 
file.write('OziExplorer Waypoint File Version 1.0\nWGS 84\nReserved 2\nReserved 3\n') 

for cid in range(55711,55801)[0:]: 
  print ('-', cid) 
  for lac in range(65537)[570:570]:    
   b = hex(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') 
   try: 
    data = urllib2.urlopen('http://www.google.com/glm/mmap',string) 
    now = datetime.datetime.now() 
    now_s = str(now.year).zfill(4) + "." + str(now.month).zfill(2) + "." + str(now.day).zfill(2) + " " + str(now.hour).zfill(2) + ":" + str(now.minute).zfill(2) + ":" + str(now.second).zfill(2) 
    r = data.read().encode('hex') 
    if len(r) > 14: 
     count_error = 0 
     lat = float(int(r[14:22],16))/1000000 
     if (lat > 360): 
      lat = lat - 2^32/1000000 
     lon = float(int(r[22:30],16))/1000000 
     if (lon > 360): 
      lon = lon - 2^32/1000000 
     r1 = int(r[30:38],16) 
     r2 = int(r[38:46],16) 
     print lat, lon, r1, r2 
     file.write('%s, %d, %d, %d, %f, %f, %d, %d\n' % (now_s, countrycode*100+operatorid, lac, cid, lat, lon, r1, r2)) 
     file.write('%d, %d-%d, %f, %f\n' % (i, lac, cid, lat ,lon)) 

    else: 
     print ('-', lac, cid, '- no data in gogle') 
   except: 
    print 'no data in google' 
    count_error = count_error+1 
  if(count_error > 20): 
    break 
file.close()
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

вот скриптик, сканирует гугл с прокси

Код: Выделить всё

# -*- coding: cp1251 -*- 
operatorid = 02 
countrycode = 250 
a = '000E00000000000000000000000000001B0000000000000000000000030000' 
net = countrycode*100+operatorid 
i, count_error = 0,0 

import urllib2,sys,datetime 

proxy = "110.172.167.35:8080" 
#proxy = "127.0.0.1:3128" 
proxy = urllib2.ProxyHandler({"http" : proxy}) 
opener = urllib2.build_opener(proxy) 
urllib2.install_opener(opener)

now = datetime.datetime.now() 
now_s = str(now.year).zfill(4) + "-" + str(now.month).zfill(2) + "-" + str(now.day).zfill(2) + "_" + str(now.hour).zfill(2) + "-" + str(now.minute).zfill(2) + "-" + str(now.second).zfill(2) + ".wpt" 
file = open(now_s,"w") 
file.write('OziExplorer Waypoint File Version 1.0\nWGS 84\nReserved 2\nReserved 3\n') 

for cid in range(57091,57099)[0:]: 
  print ('-', cid) 
  for lac in range(65537)[5058:5059]:    
   b = hex(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') 
   try: 
    data = urllib2.urlopen('http://www.google.com/glm/mmap',string) 
    now = datetime.datetime.now() 
    now_s = str(now.year).zfill(4) + "." + str(now.month).zfill(2) + "." + str(now.day).zfill(2) + " " + str(now.hour).zfill(2) + ":" + str(now.minute).zfill(2) + ":" + str(now.second).zfill(2) 
    r = data.read().encode('hex') 
    if len(r) > 14: 
     count_error = 0 
     lat = float(int(r[14:22],16))/1000000 
     if (lat > 360): 
      lat = lat - 2^32/1000000 
     lon = float(int(r[22:30],16))/1000000 
     if (lon > 360): 
      lon = lon - 2^32/1000000 
     r1 = int(r[30:38],16) 
     r2 = int(r[38:46],16) 
     print lat, lon, r1, r2 
     file.write('%s, %d, %d, %d, %f, %f, %d, %d\n' % (now_s, countrycode*100+operatorid, lac, cid, lat, lon, r1, r2)) 
     file.write('%d, %d-%d, %f, %f\n' % (i, lac, cid, lat ,lon)) 

    else: 
     print ('-', lac, cid, '- no data in gogle') 
   except: 
    print 'no data in google' 
    count_error = count_error+1 
  if(count_error > 20): 
    break 
file.close()
кому прокси не надо, комментируем строчки под #:

Код: Выделить всё

proxy = "110.172.167.35:8080" 
#proxy = "127.0.0.1:3128" 
proxy = urllib2.ProxyHandler({"http" : proxy}) 
opener = urllib2.build_opener(proxy) 
urllib2.install_opener(opener)
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

Netlog, куда прописать строчку ограничивающее координат поиска прямоугольником? и какая строчка
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

NetLog, интересно, а можно ли по запросу координат сканировать БС? а не как сейчас 8)
то есть наоборот ввёл координаты, а Гугл тебе БС шпарит
Netlog
Известный нетмониторщик
Сообщения: 469
Зарегистрирован: Пн, 02-02-2004, 21:46
Откуда: Ростов на Дону
Нетмонитор: Siemens S35
Контактная информация:

Сообщение Netlog »

Нет, обратных запросов не предвидится, у гугло-яндекса нет такой задачи, выдавать CID-LAC.
Питон - 2.5.какой то, третьим не пользуюсь.
Чтобы оквадратить координаты, можно

Код: Выделить всё

     if (lat > 360): 
      lat = lat - 2^32/1000000 
     lon = float(int(r[22:30],16))/1000000 
     if (lon > 360): 
      lon = lon - 2^32/1000000 
     r1 = int(r[30:38],16) 
     r2 = int(r[38:46],16) 
     print lat, lon, r1, r2 
     file.write('%s, %d, %d, %d, %f, %f, %d, %d\n' % (now_s, countrycode*100+operatorid, lac, cid, lat, lon, r1, r2)) 
     file.write('%d, %d-%d, %f, %f\n' % (i, lac, cid, lat ,lon))
заменить на

Код: Выделить всё

     if (lat > 360): 
      lat = lat - 2^32/1000000 
     lon = float(int(r[22:30],16))/1000000 
     if (lon > 360): 
      lon = lon - 2^32/1000000 
     r1 = int(r[30:38],16) 
     r2 = int(r[38:46],16) 
     print lat, lon, r1, r2 
     if (40.1>lat>50.2 and 30.3>lon>40.4):
      file.write('%s, %d, %d, %d, %f, %f, %d, %d\n' % (now_s, countrycode*100+operatorid, lac, cid, lat, lon, r1, r2)) 
      file.write('%d, %d-%d, %f, %f\n' % (i, lac, cid, lat ,lon))
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

спасибо, но не помогло, мусор выдаёт:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************

IDLE 2.6.2
>>> ================================ RESTART ================================
>>>
('-', 1101)
54.532872 36.16868 2654 75
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1102)
53.366824 34.104118 3117 75
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1103)
54.544518 36.148606 2797 75
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1104)
54.531837 36.169803 1659 75
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1105)
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1106)
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1107)
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1108)
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
('-', 1109)
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80
43.119868 6.128576 122000 80

и что это за циферки после координат?
Netlog
Известный нетмониторщик
Сообщения: 469
Зарегистрирован: Пн, 02-02-2004, 21:46
Откуда: Ростов на Дону
Нетмонитор: Siemens S35
Контактная информация:

Сообщение Netlog »

Да помогло. на печать то выводится всё подряд, но в файл идёт только то, что попадает в выделенный диапазон. Если и видеть не хочешь - перенеси print lat, lon, r1, r2 под if, и сдвинь на один пробел вправо.
Сам то я пишу в базу просто все ответы, ошибки, с тем, чтобы больше не запрашивать.
Первая цифирка после координат - это ошибка определения координат, размер кружочка в Гугл-картах в метрах. Чем меньшую площадь накрывает сектор, тем меньше эта цифирка. а ежели сектор светит вдоль автодороги, и с этим CID телефоны с GPSами передают координаты километров с 20 - то цифирка будет побольше. Вторая... не знаю.
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

Netlog писал(а):Да помогло. на печать то выводится всё подряд, но в файл идёт только то, что попадает в выделенный диапазон. Если и видеть не хочешь - перенеси print lat, lon, r1, r2 под if, и сдвинь на один пробел вправо.
сдвинул, ругается на ошибку в скрипте на тот же пробел
Netlog
Известный нетмониторщик
Сообщения: 469
Зарегистрирован: Пн, 02-02-2004, 21:46
Откуда: Ростов на Дону
Нетмонитор: Siemens S35
Контактная информация:

Сообщение Netlog »

В питоне нет бегинов-ендов, нет скобок, а вложенность обозначается отступами. print должен быть на таком же уровне, как и всё прочее, что выполняется под if
milk
Гость
Сообщения: 1
Зарегистрирован: Пт, 09-10-2009, 16:15

Сообщение milk »

На Дельфях и Питоне исходники уже были.
Приложу варианты на Яве и C#

Получение координат от Google
Java ME (CLDC 1.1 MIDP2.0)

Код: Выделить всё

import java.lang.*;
import java.io.*;
import javax.microedition.io 
        
// Get Lat Lon for GSM Cell from Google DB
	// double[0] - Lat; double[1] - Lon
	public static double[] GoogleLatLon(int MCC, int MNC, int LAC, int CID)
	{
		try
		{			
			HttpConnection hc = (HttpConnection)Connector.open("http://www.google.com/glm/mmap");
			hc.setRequestMethod(HttpConnection.POST);
			
			byte data[] = new byte[55];
			data[0x01] = 0x0E; // fixed
			data[0x10] = 0x1B; // fixed
			for &#40;int i = 0x2F; i <= 0x32; i++&#41; data&#91;i&#93; = &#40;byte&#41;0xFF; // fixed

			if &#40;CID > 65536&#41;
				data&#91;0x1c&#93; = 5; // UTMS - 6 hex digits
			else
				data&#91;0x1c&#93; = 3; // GSM - 4 hex digits
			
			int stOfs = 0x1f;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;CID >> 24&#41; & 0xFF&#41;; // 0x1f
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;CID >> 16&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;CID >> 8&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;CID&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;LAC >> 24&#41; & 0xFF&#41;; //0x23
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;LAC >> 16&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;LAC >> 8&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;LAC&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MNC >> 24&#41; & 0xFF&#41;; // 0x27
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MNC >> 16&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MNC >> 8&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MNC&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MCC >> 24&#41; & 0xFF&#41;; // 0x2b
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MCC >> 16&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MCC >> 8&#41; & 0xFF&#41;;
			data&#91;stOfs++&#93; = &#40;byte&#41;&#40;&#40;MCC&#41; & 0xFF&#41;;
		
			hc.setRequestProperty&#40;"Content-Type","application/binary" &#41;;
			hc.setRequestProperty&#40;"Content-Length", Integer.toString&#40;data.length&#41;&#41;;

			OutputStream os = hc.openOutputStream&#40;&#41;;
			os.write&#40;data&#41;;
			os.close&#40;&#41;;

			InputStream in = hc.openInputStream&#40;&#41;;
			byte&#91;&#93; rd = new byte&#91;15&#93;;
            int totalBytesRead = 0;
            while &#40;totalBytesRead < rd.length&#41;
                totalBytesRead += in.read&#40;rd, totalBytesRead, rd.length - totalBytesRead&#41;;				
			in.close&#40;&#41;;
			hc.close&#40;&#41;;
			
			short opcode1 = &#40;short&#41;&#40;rd&#91;0&#93; << 8 | rd&#91;1&#93;&#41;;
            byte opcode2 = rd&#91;2&#93;;
            int ret_code = &#40;int&#41;&#40;&#40;rd&#91;3&#93; << 24&#41; | &#40;rd&#91;4&#93; << 16&#41; | &#40;rd&#91;5&#93; << 8&#41; | &#40;rd&#91;6&#93;&#41;&#41;;
            if &#40;&#40;opcode1 == 0x0E&#41; && &#40;opcode2 == 0x1B&#41; && &#40;ret_code == 0&#41;&#41;
            &#123;
                double lat = &#40;&#40;double&#41;&#40;&#40;rd&#91;7&#93; << 24&#41; | &#40;rd&#91;8&#93; << 16&#41; | &#40;rd&#91;9&#93; << 8&#41; | &#40;rd&#91;10&#93;&#41;&#41;&#41; / 1000000;
                double lon = &#40;&#40;double&#41;&#40;&#40;rd&#91;11&#93; << 24&#41; | &#40;rd&#91;12&#93; << 16&#41; | &#40;rd&#91;13&#93; << 8&#41; | &#40;rd&#91;14&#93;&#41;&#41;&#41; / 1000000;
                return new double&#91;&#93; &#123; lat, lon &#125;;
            &#125;;
			return new double&#91;&#93; &#123; 0, 0 &#125;;
		&#125;
		catch &#40;Exception e&#41; &#123;&#125;;
		return new double&#91;&#93; &#123; 0, 0 &#125;;
	&#125;

Получение координат от Yandex
Java ME (CLDC 1.1 MIDP2.0)

Код: Выделить всё

import java.lang.*;
import java.io.*;
import javax.microedition.io 
// Get Lat Lon for GSM Cell from Yandex DB
	// double&#91;0&#93; - Lat; double&#91;1&#93; - Lon
	public static double&#91;&#93; YandexLatLon&#40;int MCC, int MNC, int LAC, int CID&#41;
	&#123;
		try
		&#123;			
			String url = "http&#58;//mobile.maps.yandex.net/cellid_location/"+
				"?countrycode="+Integer.toString&#40;MCC&#41;+
				"&operatorid="+Integer.toString&#40;MNC&#41;+
				"&lac="+Integer.toString&#40;LAC&#41;+
				"&cellid="+Integer.toString&#40;CID&#41;;
			HttpConnection hc = &#40;HttpConnection&#41;Connector.open&#40;url&#41;;
			hc.setRequestMethod&#40;HttpConnection.GET&#41;;
			
			InputStream in = hc.openInputStream&#40;&#41;;
			StringBuffer str = new StringBuffer&#40;&#41;;
            int ch;
            while &#40;&#40;ch = in.read&#40;&#41;&#41; != -1&#41; str.append&#40;&#40;char&#41;ch&#41;;
			in.close&#40;&#41;;
			hc.close&#40;&#41;;
			
			String s = str.toString&#40;&#41;;
			int iLat = s.indexOf&#40;" latitude"&#41;+11; // space + latitude="
			String sLat = s.substring&#40;iLat,s.indexOf&#40;"\"",iLat&#41;&#41;;
			int iLon = s.indexOf&#40;" longitude"&#41;+12; // space + longitude="
			String sLon = s.substring&#40;iLon,s.indexOf&#40;"\"",iLon&#41;&#41;;
			return new double&#91;&#93; &#123; Double.parseDouble&#40;sLat&#41;, Double.parseDouble&#40;sLon&#41; &#125;;
		&#125;
		catch &#40;Exception e&#41; &#123;&#125;;
		return new double&#91;&#93; &#123; 0, 0 &#125;;
	&#125;
	
Класс на C# (.Net 2.0 .Net CF 2.0)

Код: Выделить всё

using System;
using System.IO;
using System.Net;
using System.Xml;

namespace CellInform
&#123;
    /// <summary>
    ///     Cell Information DataBase Request Class
    /// </summary>
    class CellDBCall
    &#123;        
        /// <summary>
        ///     Prepare to HTTP POST Cell Information 
        /// </summary>
        /// <param name="MCC">Mobile Country Code</param>
        /// <param name="MNC">Mobile Network Code</param>
        /// <param name="LAC">Local Area Code</param>
        /// <param name="CID">Cell Identifier</param>
        /// <returns>byte&#91;&#93; for HTTP POST</returns>
        private static byte&#91;&#93; EncodeData&#40;int MCC, int MNC, int LAC, int CID&#41;
        &#123;
            byte&#91;&#93; result = new byte&#91;55&#93;;
            result&#91;0x01&#93; = 0x0E; // fixed
            result&#91;0x10&#93; = 0x1B; // fixed
            for &#40;int i = 0x2F; i <= 0x32; i++&#41; result&#91;i&#93; = &#40;byte&#41;0xFF; // fixed

            if &#40;CID > 65536&#41;
                result&#91;0x1c&#93; = 5; // UTMS - 6 hex digits
            else
                result&#91;0x1c&#93; = 3; // GSM - 4 hex digits

            // MSB..LSB
            int endOffset = 0x2e;
            foreach &#40;byte b in BitConverter.GetBytes&#40;MCC&#41;&#41; result&#91;endOffset--&#93; = b; // 0x2e .. 0x2b // 0x1f -- CID -- 0x22
            foreach &#40;byte b in BitConverter.GetBytes&#40;MNC&#41;&#41; result&#91;endOffset--&#93; = b; // 0x2a .. 0x27 // 0x23 -- LAC -- 0x26
            foreach &#40;byte b in BitConverter.GetBytes&#40;LAC&#41;&#41; result&#91;endOffset--&#93; = b; // 0x26 .. 0x23 // 0x27 -- MNC -- 0x2a
            foreach &#40;byte b in BitConverter.GetBytes&#40;CID&#41;&#41; result&#91;endOffset--&#93; = b; // 0x22 .. 0x1f // 0x2b -- MCC -- 0x2e
            return result;
        &#125;

        
        /// <summary>
        ///     Locate Cell in Google CDB
        /// </summary>
        /// <param name="MCC">Mobile Country Code</param>
        /// <param name="MNC">Mobile Network Code</param>
        /// <param name="LAC">Local Area Code</param>
        /// <param name="CID">Cell Identifier</param>
        /// <param name="proxy">Proxy Server</param>
        /// <returns>&#91;0&#93; - Latitude, &#91;1&#93; - Longitude</returns>
        public static double&#91;&#93; GoogleLatLon&#40;int MCC, int MNC, int LAC, int CID&#41;
        &#123;
            HttpWebRequest req = &#40;HttpWebRequest&#41;WebRequest.Create&#40;"http&#58;//www.google.com/glm/mmap"&#41;;
            req.UserAgent = "Firefox/3.0";
            req.Method = "POST";
            byte&#91;&#93; data = EncodeData&#40;MCC, MNC, LAC, CID&#41;;
            req.ContentType = "application/binary";
            req.ContentLength = data.Length;

            Stream outputStream = req.GetRequestStream&#40;&#41;;
            outputStream.Write&#40;data, 0, data.Length&#41;;
            outputStream.Close&#40;&#41;;

            HttpWebResponse res = &#40;HttpWebResponse&#41;req.GetResponse&#40;&#41;;
            byte&#91;&#93; rd = new byte&#91;res.ContentLength&#93;;
            int totalBytesRead = 0;
            while &#40;totalBytesRead < rd.Length&#41;
                totalBytesRead += res.GetResponseStream&#40;&#41;.Read&#40;rd, totalBytesRead, rd.Length - totalBytesRead&#41;;

            if &#40;res.StatusCode == HttpStatusCode.OK&#41;
            &#123;
                short opcode1 = &#40;short&#41;&#40;rd&#91;0&#93; << 8 | rd&#91;1&#93;&#41;;
                byte opcode2 = rd&#91;2&#93;;
                int ret_code = &#40;int&#41;&#40;&#40;rd&#91;3&#93; << 24&#41; | &#40;rd&#91;4&#93; << 16&#41; | &#40;rd&#91;5&#93; << 8&#41; | &#40;rd&#91;6&#93;&#41;&#41;;
                if &#40;&#40;opcode1 == 0x0E&#41; && &#40;opcode2 == 0x1B&#41; && &#40;ret_code == 0&#41;&#41;
                &#123;
                    double lat = &#40;&#40;double&#41;&#40;&#40;rd&#91;7&#93; << 24&#41; | &#40;rd&#91;8&#93; << 16&#41; | &#40;rd&#91;9&#93; << 8&#41; | &#40;rd&#91;10&#93;&#41;&#41;&#41; / 1000000;
                    double lon = &#40;&#40;double&#41;&#40;&#40;rd&#91;11&#93; << 24&#41; | &#40;rd&#91;12&#93; << 16&#41; | &#40;rd&#91;13&#93; << 8&#41; | &#40;rd&#91;14&#93;&#41;&#41;&#41; / 1000000;
                    return new double&#91;&#93; &#123; lat, lon &#125;;
                &#125;;
            &#125;;
            return new double&#91;&#93; &#123; 0, 0 &#125;;
        &#125;

        /// <summary>
        ///     Locate Cell in Yandex CDB
        /// </summary>
        /// <param name="MCC">Mobile Country Code</param>
        /// <param name="MNC">Mobile Network Code</param>
        /// <param name="LAC">Local Area Code</param>
        /// <param name="CID">Cell Identifier</param>
        /// <returns>&#91;0&#93; - Latitude, &#91;1&#93; - Longitude</returns>
        public static double&#91;&#93; YandexLatLon&#40;int MCC, int MNC, int LAC, int CID&#41;
        &#123;
            string url = "http&#58;//mobile.maps.yandex.net/cellid_location/?countrycode=&#123;0&#125;&operatorid=&#123;1&#125;&lac=&#123;2&#125;&cellid=&#123;3&#125;";
            url = String.Format&#40;url, new object&#91;&#93; &#123; MCC, MNC, LAC, CID &#125;&#41;;
            HttpWebRequest req = &#40;HttpWebRequest&#41;WebRequest.Create&#40;url&#41;;
            req.UserAgent = "Firefox/3.0";
            req.Method = "GET";

            HttpWebResponse res = &#40;HttpWebResponse&#41;req.GetResponse&#40;&#41;;
            Stream get = res.GetResponseStream&#40;&#41;;
            byte&#91;&#93; rData =  new byte&#91;res.ContentLength&#93;;
            get.Read&#40;rData, 0, rData.Length&#41;;            
            get.Close&#40;&#41;;

            XmlDocument xd = new XmlDocument&#40;&#41;;
            xd.LoadXml&#40;System.Text.Encoding.GetEncoding&#40;1251&#41;.GetString&#40;rData&#41;&#41;;
            XmlNode xnLat = xd.SelectSingleNode&#40;"/location/coordinates/@latitude"&#41;;
            XmlNode xnLon = xd.SelectSingleNode&#40;"/location/coordinates/@longitude"&#41;;

            return new double&#91;&#93; &#123; double.Parse&#40;xnLat.Value, YaNoFInfo&#41;, double.Parse&#40;xnLon.Value, YaNoFInfo&#41; &#125;;
        &#125;

        /// <summary>
        ///     Use for parse double in Yandex result
        /// </summary>
        private static System.Globalization.NumberFormatInfo YaNoFInfo
        &#123;
            get
            &#123;
                System.Globalization.NumberFormatInfo nf = new System.Globalization.NumberFormatInfo&#40;&#41;;
                nf.NumberDecimalSeparator = ".";
                return nf;
            &#125;
        &#125;
    &#125;
&#125;
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

выкладываю простенький скрипт для Гугла с прокси

Код: Выделить всё

net, lac, rnc = 25501, 570, 0
import urllib2

proxy = "любой прокси"

proxy = urllib2.ProxyHandler&#40;&#123;"http" &#58; proxy&#125;&#41;
opener = urllib2.build_opener&#40;proxy&#41;
urllib2.install_opener&#40;opener&#41;

a, i = '000E00000000000000000000000000001B0000000000000000000000030000', 0
file = open&#40;"ozi.wpt","w"&#41;
file.write&#40;'OziExplorer Waypoint File Version 1.0\nWGS 84\nReserved 2\nReserved 3\n'&#41;
try&#58;
 for cid in range&#40;65536&#41;&#91;10001&#58;11006&#93;&#58;
  b = hex&#40;rnc*65536+cid&#41;&#91;2&#58;&#93;.zfill&#40;8&#41; + hex&#40;lac&#41;&#91;2&#58;&#93;.zfill&#40;8&#41;
  c = hex&#40;divmod&#40;net,100&#41;&#91;1&#93;&#41;&#91;2&#58;&#93;.zfill&#40;8&#41; + hex&#40;divmod&#40;net,100&#41;&#91;0&#93;&#41;&#91;2&#58;&#93;.zfill&#40;8&#41;
  string = &#40;a + b + c + 'FFFFFFFF00000000'&#41;.decode&#40;'hex'&#41;
  data = urllib2.urlopen&#40;'http&#58;//www.google.com/glm/mmap',string&#41;
  r = data.read&#40;&#41;.encode&#40;'hex'&#41;
  if len&#40;r&#41; > 14 and int&#40;r&#91;22&#58;23&#93;,16&#41;==0 &#58;
   x, y, i = float&#40;int&#40;r&#91;14&#58;22&#93;,16&#41;&#41;/1000000, float&#40;int&#40;r&#91;22&#58;30&#93;,16&#41;&#41;/1000000, i+1
   print cid, '-', x, y
   file.write&#40;'%d, %d, %f, %f\n' % &#40;i, cid, x, y&#41;&#41;
except&#58;
 print 'connect error'
file.close&#40;&#41;
кому прокси не нужны, можно закоментировать решёткой начало каждой из строк

Код: Выделить всё

#proxy = "212.89.11.170&#58;8080"

#proxy = urllib2.ProxyHandler&#40;&#123;"http" &#58; proxy&#125;&#41;
$opener = urllib2.build_opener&#40;proxy&#41;
superemo
Начинающий нетмониторщик
Сообщения: 7
Зарегистрирован: Вс, 29-11-2009, 16:56
Откуда: Sofia,BG
Нетмонитор: Android LG GT540 & Nokia 6120c & Nokia 3310 Netmonitor

Сообщение superemo »

@McMaster,
Спасибо за легкого кода на скрипт.

Я хочу собирать БД для наше место, но я не знаю какие та лимитьй относно гоогле запросами :?:
Например 1000 для час, день ...
Есть ли вариант използую anonymous.org, чтобы обойти гоогле IP бан?
McMaster
Известный нетмониторщик
Сообщения: 637
Зарегистрирован: Вс, 29-05-2005, 13:44
Откуда: Московская область
Нетмонитор: HTC Artemis, Nokia 6600 (CellTrack+FTD)

Сообщение McMaster »

поделитесь пожайлуста новым скриптом для яндекс, яндекс запросы изменил или ответы
Ответить