yf_yzl %!s(int64=2) %!d(string=hai) anos
pai
achega
3b28f03d8e
Modificáronse 1 ficheiros con 17 adicións e 5 borrados
  1. 17 5
      smartfarming/utils.py

+ 17 - 5
smartfarming/utils.py

@@ -290,11 +290,23 @@ def get_weather_info(lng=None, lat=None):
     data = {}
     if lng and lat:
         try:
-            url = "http://114.115.147.140:8080/weather"
-            res = requests.post(url, {"lat": lat, "lng": lng})
-            result = res.json()
-            if result['status'] == 'true':
-                data = result['data']
+            url = "http://open.nyzhwlw.com:10001/yf_weather"
+            response = requests.post(
+                url=url,
+                data={
+                    "province": "黑龙江省", 
+                    "city": "齐齐哈尔市", 
+                    "username": "yfkj_weather", 
+                    "district": "克东县", 
+                    "password": "1qaz!QAZ", 
+                    "day_type": 1
+                }
+            )
+            if response.status_code == 200:
+                result = json.loads(response.text)
+                data = result.get("data")
+                if data:
+                    data = data.get("content")
         except Exception as e:
             pass
     return data