Ejemplo n.º 1
0
 def get_all_results(self):
     self._db_cur.execute('SELECT * FROM result', ())
     results = []
     row = self._db_cur.fetchone()
     while row:
         result = Result()
         result.request_id = row[1]
         result.adress = row[3]
         result.square = row[6]
         result.region_id = row[8]
         results.append(result)
         row = self._db_cur.fetchone()
     return results
Ejemplo n.º 2
0
def search_flat(search_form, request_id):
    payload = utils.create_form_data(search_form.__dict__)
    res = requests.post('https://extra.egrp365.ru/api/extra/index.php',
                        data=payload.encode('utf-8'),
                        headers=utils.HEADERS)
    try:
        json_data = json.loads(res.text)
        if json_data['success']:
            db = DB()
            for x in json_data['data']:
                result = Result()
                result.cadastral = x['cn']
                result.adress = x['address']
                result.floor = x['floor']
                # result.response_json = str(json_data)
                result.region_id = search_form.macroRegionId
                result.square = square_search(result.cadastral)
                db.insert(result, 'result')
        else:
            SEARCH_SHEDULE.append_request(request_id)
    except Exception as e:
        logging.error('Search error. Response text: ' + res.text)
        raise e