From 0662c770a6974ec3ab455f010b95721da7594a95 Mon Sep 17 00:00:00 2001 From: mjz <1104134852@qq.com> Date: Sun, 11 Oct 2026 19:28:15 +0800 Subject: [PATCH] upload --- 跑_IP定位.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 跑_IP定位.py diff --git a/跑_IP定位.py b/跑_IP定位.py new file mode 100644 index 0000000..b4355a7 --- /dev/null +++ b/跑_IP定位.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +"""实测美团定位 SDK 的 network 通道, 看能否按 IP 返回位置。 + +来源: h5.waimai.meituan.com 首页包 index.0f6b961e.js 里的定位 SDK + 接口 : POST {mars.meituan.com}/locate/v3/sdk/loc + body : 不带 location 字段 -> 服务端按请求来源 IP 定位 +""" +import json +import sys +import time +import warnings + +import requests + +warnings.filterwarnings("ignore") + +sys.stdout.reconfigure(encoding="utf-8") # 终端默认 GBK, 不改打印中文乱码 + +# 首页定位 SDK 的配置 (index 包内 G 对象) +LOC_KEY = "48779dc57b66313d303b72616ada6c19" # X-Request-Source +LOC_PROJECT = "wm_open_h5" # X-Request-Agent 里的 project +LOC_VERSION = "0.8.15" # Location-SDK 版本 +LOC_PREJECT_VERSION = "2.0" # X-Request-Agent 里的 project 版本 +LOC_URL = "https://mars.meituan.com/locate/v3/sdk/loc" # prod 域名 +UUID = "2096194299624722486" # 从抓包 cookie 里取的 _lxsdk, 可换 + +headers = { + "X-Request-Source": LOC_KEY, + "X-Request-Medium": "uuid:" + UUID, + "X-Request-Pivot": "meituan:", + "X-Request-ID": str(int(time.time() * 1000)), + "X-Request-Agent": "Location-SDK/%s %s/%s" % (LOC_VERSION, LOC_PROJECT, LOC_PREJECT_VERSION), + "X-Request-Platform": "6", + "Content-Type": "application/json", +} + +# 不带 location 就是纯 IP 定位; need_address=1 让服务端返回城市/地址 +body = { + "need_openCity": 1, # 1=meituan 2=dianping 3=all + "need_address": True, + "coord_type": "GCJ02", +} + +# 带坐标时的形态 (对照用): 有 location 就是"按坐标逆地理", 不是 IP 定位 +# body_with_geo = { +# "need_openCity": 1, +# "need_address": True, +# "coord_type": "GCJ02", +# "location": {"id": 1, "longitude": 113.299172, "latitude": 23.129393, "accuracy": -1, "type": "GCJ02", "source": "network"}, +# } + + +def run_ip_locate(prox): + req = requests.post(LOC_URL, headers=headers, data=json.dumps(body), verify=False, timeout=20, proxies=prox) + resp_data = req.json() + location = resp_data["data"]["location"] + address = resp_data["data"]["address"] + print("IP :", prox,'\t','位置 :', location['latitude'], location['longitude'], address["city"], address["district"], address["township"], address["detail"]) + return req + + +if __name__ == '__main__': + ip_list = [ + {"http": "http://uuvg:uuvgt@2p3c.smart.51tcp.net:21209", "https": "http://uuvg:uuvgt@2p3c.smart.51tcp.net:21209"}, + ] + for ip in ip_list: + run_ip_locate(ip)