예제 #1
0
def getKeyListExceptToday(re):
    """
    获取除了今天以外的所有key的列表
    :return:
    """
    today = time.strftime("%Y_%m_%d")
    keyList = re.keys(tool.getFileKey() + '_*')
    try:
        keyList.remove(tool.getFileKey() + '_' + today)
    except Exception as e:
        pass
    return keyList
예제 #2
0
def getGoneDiffData(re):
    """
    获取消失的数据
    :param re:
    :return:
    """
    today = time.strftime("%Y_%m_%d")
    if tool.getFileKey() + '_' + today in getKeyList(re):
        re.delete(tool.getFileKey() + 'gone')
        re.sdiffstore(tool.getFileKey() + 'gone',
                      tool.getFileKey() + 'union',
                      tool.getFileKey() + '_' + today)
    else:
        pass
예제 #3
0
def getNewDiffData(re):
    """
    获取新增的数据
    :param re:
    :return:
    """
    today = time.strftime("%Y_%m_%d")
    if 'train_' + today in getKeyList(re):
        re.delete(tool.getFileKey() + 'new')
        re.sdiffstore(tool.getFileKey() + 'new',
                      tool.getFileKey() + '_' + today,
                      tool.getFileKey() + 'uniontmp')
    else:
        pass
예제 #4
0
def getUnionData(re):
    """
    获得所有数据的并集并保存到trainunion中
    :param re:
    :return:
    """
    keyList = getKeyList(re)
    re.sunionstore(tool.getFileKey() + 'union', keyList)
    try:
        re.delete(tool.getFileKey() + 'unionmp')
    except Exception as e:
        pass
    finally:
        re.sunionstore(tool.getFileKey() + 'uniontmp',
                       getKeyListExceptToday(re))
예제 #5
0
def main():
    today = time.strftime("%Y_%m_%d")
    todayKey = tool.getFileKey() + '_' + today
    re = connectRedis()
    en = connectMysql()
    # 将今日数据写入mysql
    redisToMysql(re, en, todayKey, 'respage02', True)
예제 #6
0
def main():
    today = time.strftime("%Y_%m_%d")
    todayKey = tool.getFileKey() + '_' + today
    newKey = tool.getFileKey() + 'new'
    goneKey = tool.getFileKey() + 'gone'
    unionKey = tool.getFileKey() + 'union'
    re = connectRedis()
    en = connectMysql()
    getUnionData(re)
    getGoneDiffData(re)
    getNewDiffData(re)
    # 将今日数据写入mysql
    redisToMysql(re, en, todayKey, 'respage01', True)
    # 将今日新增数据写入mysql
    redisToMysql(re, en, newKey, 'respage01New', False)
    # 将今日消失数据写入mysql
    redisToMysql(re, en, goneKey, 'respage01Gone', False)
    # 将并集数据写入mysql
    redisToMysql(re, en, unionKey, 'respage01Union', False)
예제 #7
0
def main():
    today = time.strftime("%Y_%m_%d")
    setName = tool.getFileKey() + "_" + today
    try:
        re = connectRedis()
        for line in fileinput.input(mode='rb'):
            re.sadd(setName, line.decode('utf-8').strip())
        exit(0)
    except Exception as e:
        print(e)
        exit(-1)
예제 #8
0
# coding: utf-8
import requests
import json
import time
from tool.tool import tool
import io
import sys
import multiprocessing
import asyncio

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
"""
    查询关键字:
"""
FileKey = tool.getFileKey()
"""
    关注区域的左下角和右上角百度地图坐标
    全市:
    BigRect = {
    'left': {
        'x': 119.58962425017401,
        'y': 29.02371358317696
    },
    'right': {
        'x': 119.787499394624553,
        'y': 29.149153586357146
    }
}
"""
BigRect1 = {
    'left': {
예제 #9
0
def getKeyList(re):
    """
    获取所有的key的列表
    :return:
    """
    return re.keys(tool.getFileKey() + "_*")