예제 #1
0
def do_import(mail_type):
    mail_db = db.get_local_mailer_db()
    cursor = mail_db.cursor()
    start = 1
    end = 31
    while start <= end:
        f = open("C:\\Users\\duqing\\Desktop\\reqq\\"
                 "reqq-" + str(start) + "-result.txt")  # 返回一个文件对象
        lines = f.readlines()
        try:
            for line in lines:
                try:
                    if line.strip() == '':
                        continue
                    detail = line.split('-')
                    if len(detail) < 2:
                        continue
                    status = detail[1]
                    if status.strip() == '250':
                        status = 1
                    else:
                        status = 2
                    email = detail[0]
                    sql = '''insert ignore into resume_email ( email_dq, type, status ) values ( '%s', %d, %d )''' % (
                        email, mail_type, status)
                    cursor.execute(sql)
                    print email
                except Exception, e:
                    print line, ' Exception:', e
        except Exception, e:
            print line, ' Exception:', e
        start += 1
예제 #2
0
def compare(file1):
    f1 = open(file1)
    # f2 = open(file2)
    lines1 = f1.readlines()
    # lines2 = f2.readlines()
    fp = open("C:\\Users\\duqing\\Desktop\\result20150813.txt", 'a')
    localdb = db.get_local_mailer_db()
    cursor = localdb.cursor()
    for line1 in lines1:
        sql = '''select email_dq from fenzhi_email where lower(email_dq) ='%s' and status=1 '''
        if line1.strip() == '':
            continue
        detail = line1.split('@')
        if len(detail) != 2:
            continue
        sql %= line1.strip().lower()
        cursor.execute(sql)
        if cursor.rowcount > 0:
            fp.write(line1.strip().lower())
예제 #3
0
def do_import_163(mail_type):
    mail_db = db.get_local_mailer_db()
    cursor = mail_db.cursor()

    f = open("C:\\Users\\duqing\\Desktop\\fenzhi163\\163-6user.txt")  # 返回一个文件对象
    status = 1  # 有效
    lines = f.readlines()
    try:
        for line in lines:
            try:
                if line.strip() == '':
                    continue
                email = line.strip()
                sql = '''insert ignore into fenzhi_email ( email_dq, type, status ) values ( '%s', %d, %d )''' % (
                    email, mail_type, status)
                cursor.execute(sql)
                print email
            except Exception, e:
                print line, ' Exception:', e
    except Exception, e:
        print line, ' Exception:', e
예제 #4
0
def do_import_other(mail_type):
    mail_db = db.get_local_mailer_db()
    cursor = mail_db.cursor()
    start = 1
    end = 31
    while start <= end:
        f = open("C:\\Users\\duqing\\Desktop\\reother\\reother-" + str(start) + "-result.txt")
        status = 1  # 有效
        lines = f.readlines()
        try:
            for line in lines:
                try:
                    if line.strip() == '':
                        continue
                    email = line.strip()
                    sql = '''insert ignore into resume_email ( email_dq, type, status ) values ( '%s', %d, %d )''' % (
                        email, mail_type, status)
                    cursor.execute(sql)
                    print email
                except Exception, e:
                    print line, ' Exception:', e
        except Exception, e:
            print line, ' Exception:', e
        start += 1