80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
import os, django
|
|
import requests
|
|
import requests.exceptions as rex
|
|
import sys
|
|
import calendar
|
|
import uuid
|
|
import datetime as DT
|
|
import pytz
|
|
import json
|
|
#import maya
|
|
import random
|
|
import time
|
|
import traceback
|
|
from dateutil import tz
|
|
from tqdm import tqdm
|
|
import pandas as pd
|
|
|
|
from datetime import datetime, timedelta,date
|
|
from requests.auth import HTTPBasicAuth
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mfssogr.settings')
|
|
django.setup()
|
|
|
|
from django.db.models import Q
|
|
|
|
import apps.schedulers.tasks
|
|
|
|
from apps.seismicproc.models.model_earthquake import Earthquake
|
|
|
|
from bs4 import BeautifulSoup
|
|
from sabron.util import logging
|
|
|
|
def zone_check():
|
|
try:
|
|
response = requests.get('http://www.gsras.ru/cgi-bin/new/mapCustom.pl?l=0&lat=55&lon=86&num=50&rad=1000')
|
|
bs = BeautifulSoup(response.text,"lxml")
|
|
table = bs.find(id="tableQuakes")
|
|
table_body = table.find('tbody')
|
|
rows = table_body.find_all('tr')
|
|
data = []
|
|
for row in rows:
|
|
cols = row.find_all('td')
|
|
date = cols[1].text.strip()
|
|
latitude = cols[2].text.strip()
|
|
longitude = cols[3].text.strip()
|
|
depth = cols[4].text.strip()
|
|
magnitude = cols[7].text.strip()
|
|
region = cols[9].text.strip()
|
|
print(region)
|
|
myfileter = Q(date_time = date)
|
|
myfileter &= Q(latitude = latitude)
|
|
myfileter &= Q(longitude = longitude)
|
|
earthquake = Earthquake.objects.filter(myfileter).first()
|
|
if earthquake is None:
|
|
Earthquake.objects.create(date_time = date,
|
|
latitude = latitude,
|
|
longitude = longitude,
|
|
depth = depth,
|
|
magnitude = magnitude,
|
|
region = region)
|
|
except Exception as err:
|
|
logging.error(traceback.format_exc())
|
|
|
|
|
|
def radius(latitude,longitude):
|
|
LATITUDE_KEY = latitude
|
|
LONGITUDE_KEY = longitude
|
|
columns = [ \
|
|
# stuff and
|
|
LATITUDE_KEY,
|
|
LONGITUDE_KEY
|
|
]
|
|
|
|
nodes = pd.read_csv('place_nodes.csv', names=columns)
|
|
nodes = nodes[nodes[LATITUDE_KEY].between(LAT_MIN, LAT_MAX) \
|
|
& nodes[LONGITUDE_KEY].between(LONG_MIN, LONG_MAX)]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
radius(10.111,41.000)
|