Spaces:
hstz
/
Running

hstz commited on
Commit
95dfc47
·
verified ·
1 Parent(s): 6d5a039

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -22
main.py CHANGED
@@ -150,37 +150,39 @@ def get_maxmind(ip: str):
150
  ret["addr"] = get_addr(ip, prefix)
151
  if not city_info:
152
  return ret
153
-
154
- # 添加经纬度信息
155
  if "location" in city_info:
156
  location = city_info["location"]
157
  ret["location"] = {
158
  "latitude": location.get("latitude"),
159
- "longitude": location.get("longitude")
 
160
  }
161
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  if "country" in city_info:
163
  country_code = city_info["country"]["iso_code"]
164
  country_name = get_country(city_info["country"])
165
  ret["country"] = {"code":country_code,"name":country_name}
166
-
167
- if "registered_country" in city_info:
168
- registered_country_code = city_info["registered_country"]["iso_code"]
169
- ret["registered_country"] = {"code":registered_country_code,"name":get_country(city_info["registered_country"])}
170
-
171
- regions = [get_des(i) for i in city_info.get('subdivisions', [])]
172
-
173
-
174
- if "city" in city_info:
175
- c = get_des(city_info["city"])
176
- if (not regions or c not in regions[-1])and c not in country_name:
177
- regions.append(c)
178
-
179
- regions = de_duplicate(regions)
180
- if regions:
181
- ret["regions"] = regions
182
-
183
- return ret
184
 
185
  def get_cn(ip:str, info={}):
186
  ret, prefix = cn_reader.get_with_prefix_len(ip)
 
150
  ret["addr"] = get_addr(ip, prefix)
151
  if not city_info:
152
  return ret
153
+
154
+ # 添加经纬度和时区信息
155
  if "location" in city_info:
156
  location = city_info["location"]
157
  ret["location"] = {
158
  "latitude": location.get("latitude"),
159
+ "longitude": location.get("longitude"),
160
+ "timezone": location.get("time_zone")
161
  }
162
+
163
+ # 添加大洲信息
164
+ if "continent" in city_info:
165
+ ret["continent"] = {
166
+ "code": city_info["continent"]["code"],
167
+ "name": get_des(city_info["continent"])
168
+ }
169
+
170
+ # 添加邮政编码
171
+ if "postal" in city_info:
172
+ ret["postal"] = city_info["postal"].get("code")
173
+
174
+ # 添加网络特征
175
+ if "traits" in city_info:
176
+ traits = city_info["traits"]
177
+ ret["traits"] = {
178
+ "is_anonymous_proxy": traits.get("is_anonymous_proxy", False),
179
+ "is_satellite_provider": traits.get("is_satellite_provider", False)
180
+ }
181
+
182
  if "country" in city_info:
183
  country_code = city_info["country"]["iso_code"]
184
  country_name = get_country(city_info["country"])
185
  ret["country"] = {"code":country_code,"name":country_name}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
  def get_cn(ip:str, info={}):
188
  ret, prefix = cn_reader.get_with_prefix_len(ip)