|
|
@@ -86,17 +86,18 @@ def main():
|
|
|
pid = row.pid # 110100000000
|
|
|
province_id = city_id[:2]
|
|
|
province = province_dict.get(province_id)
|
|
|
- if len(pid) == 2:
|
|
|
- # 处理 市辖区
|
|
|
- city = temp
|
|
|
+ if len(pid) == 2 and city == "市辖区":
|
|
|
+ # 处理 市辖区 只有两级,区为空
|
|
|
+ city = province
|
|
|
+ district = "市辖区"
|
|
|
+ elif len(pid) ==2 and city != "市辖区":
|
|
|
+ # 三级 省 市 区(县)
|
|
|
+ city = temp
|
|
|
district = ""
|
|
|
else:
|
|
|
- te = District.objects.filter(city_id=pid).first()
|
|
|
- city = te.city
|
|
|
+ dis = District.objects.get(city_id=pid)
|
|
|
+ city = dis.city
|
|
|
district = temp
|
|
|
- if city == "市辖区":
|
|
|
- city = district
|
|
|
- district = ""
|
|
|
|
|
|
try:
|
|
|
today_url = f"https://v0.yiketianqi.com/api?unescape=1&version=v62&appid={app_id}&appsecret={app_secret}&adcode={city_id}"
|