示例#1
0
def webLabel():

    sql = """
        SELECT number FROM risk_number_label
    """
    num = equery.execute_select(dbconfig.RISK_CONFIG, sql)
    numlist = [str(int(number['number'])) for number in num]
    update_label(numlist, 'web')
示例#2
0
def get_userInfo(sql, filename):
    """ 获取用户基本信息 """

    userInfo = equery.execute_select(dbconfig.MAIN_CONFIG, sql)
    userdata = pd.DataFrame(userInfo)
    userdata.to_csv(filename, index=False, encoding="utf-8")

    userdata = pd.read_csv(filename, encoding="utf-8")
    userdata['phone'] = [phone[2:-1] for phone in userdata['phone']]
    userdata['id_num'] = [id_num[2:-1] for id_num in userdata['id_num']]
    userdata.to_csv(filename, index=False, encoding="utf-8")
示例#3
0
def contact_item_info(user):
    """ 获取每个人的运营商数据 """

    sql = """
        SELECT user_id,receive_phone,count(*) 'num'
        FROM third_mobile_tel_data
        WHERE user_id = '{}' AND call_type = 1 and receive_phone is not null
        GROUP BY receive_phone
        HAVING count(*) >= 2 
    """.format(user[0])

    filename = user[1] + user[0] + '.csv'
    userContact = equery.execute_select(dbconfig.RISK_CONFIG, sql)
    if userContact:
        contactdata = pd.DataFrame(userContact)
        contactdata.to_csv(filename, index=False)
示例#4
0
def query_group():

    user_id = '6bad659bb6234b08b24787d11e5762a0'
    phoneId = '15777670597'

    sql = """
        SELECT user_id,receive_phone,count(*) 'num'
        FROM third_mobile_tel_data
        WHERE user_id = '{}' AND call_type = 1 AND receive_phone IS NOT NULL
        GROUP BY receive_phone
        HAVING count(*) >= 2
    """.format(user_id)

    userInfo = equery.execute_select(dbconfig.RISK_CONFIG, sql)
    content_list = [(item.get('receive_phone'), item.get('num')) for item in userInfo]

    content_dict = {}
    for phone, num in content_list:
        plabel = phone if not phone.startswith('0') else phone[1:]
        content_dict[plabel] = num

    jsondict = findgroup_api(content_dict, phoneId)
    json.dump(jsondict,open('html/temp.json','w'))
示例#5
0
def query_one():

    user_id = '7336dfc7597d46bfab2c68f841ef479d'
    phoneId = '15077694366'

    sql = """
        SELECT user_id,receive_phone,count(*) 'num'
        FROM third_mobile_tel_data
        WHERE user_id = '{}' AND call_type = 1 AND receive_phone IS NOT NULL
        GROUP BY receive_phone
        HAVING count(*) >= 2
    """.format(user_id)

    userInfo = equery.execute_select(dbconfig.RISK_CONFIG, sql)
    content_list = [(item.get('receive_phone'), item.get('num')) for item in userInfo]

    content_dict = {}
    for phone, num in content_list:
        plabel = phone if not phone.startswith('0') else phone[1:]
        content_dict[plabel] = num

    #record = find_label(content_dict, phoneId)
    record = find_api(content_dict, phoneId)
    print(record)
示例#6
0
def query_maney():

    user = pd.read_csv('data/testuser.csv')
    k,j,jbad,jblack,jblackgroup,jinterblack1,jinterblack2,jweb,jbank = 0,0,0,0,0,0,0,0,0

    for i in range(len(user)):
        userId = user.ix[i]['id']
        phoneId = user.ix[i]['phone']

        sql = """
            SELECT user_id,receive_phone,count(*) 'num'
            FROM third_mobile_tel_data
            WHERE user_id = '{}' AND call_type = 1 AND receive_phone IS NOT NULL
            GROUP BY receive_phone
            HAVING count(*) >= 2
        """.format(userId)

        userInfo = equery.execute_select(dbconfig.RISK_CONFIG, sql)
        content_list = [(item.get('receive_phone'), item.get('num')) for item in userInfo]

        content_dict = {}
        for phone, num in content_list:
            plabel = phone if not phone.startswith('0') else phone[1:]
            content_dict[plabel] = num

        #record = find_label(content_dict, phoneId)
        jsondict = find_api(content_dict, phoneId)
        
        if jsondict['label'] is None:
            j += 1
            if all([value is None for value in jsondict.values()]):
                k += 1
            if jsondict['bad'] is None:
                jbad += 1
            if jsondict['black'] is None:
                jblack += 1
            if jsondict['blackgroup'] is None:
                jblackgroup += 1
            if jsondict['interblack1'] is None:
                jinterblack1 += 1
            if jsondict['interblack2'] is None:
                jinterblack2 += 1
            if jsondict['web'] is None:
                jweb += 1
            if jsondict['bank'] is None:
                jbank += 1

        print(userId)
        print(phoneId)
        print(jsondict)

    print('未覆盖量:'+ str(k))
    print('未存在于数据库的量:' + str(j))
    print('总测试量:'+ str(len(user)))

    print('jbad:'+str(jbad))
    print('jblack:'+str(jblack))
    print('jblackgroup:'+str(jblackgroup))
    print('jinterblack1:'+str(jinterblack1))
    print('jinterblack2:'+str(jinterblack2))
    print('jweb:'+str(jweb))
    print('jbank:'+str(jbank))