Exemplo n.º 1
0
 def __init__(self, source, id_num, phone_num, name, email, seged_dict):
     self.json_source = source
     self.id_num = id_num
     self.sql_config = common.sql_config
     self.phone_num = phone_num
     self.name = name
     self.email = email
     self.seged_dict = seged_dict
     self.logger = common.log_init(__name__, 'buy2talent.log')
Exemplo n.º 2
0
 def __init__(self, source, json_dict, job_category='', source_id=''):
     # with open(json_dict) as f:
     #     self.json_dict = json.load(f)
     # self.job_detail = self.json_dict
     #
     self.json_source = source
     if len(source_id) > 0:
         json_dict['id'] = source_id
         if source == 'cjol' and not source_id.startswith('J'):
             json_dict['id'] = 'J' + source_id
     self.job_detail = json_dict
     self.job_category = job_category
     # self.job_detail = self.json_dict['job_detail']
     # self.json_dict = json_dict
     # self.sql_config = {
     #         'host': "10.4.14.233",
     #         'user': "******",
     #         'passwd': "sv8VW6VhmxUZjTrU",
     #         'db': 'tuike',
     #         'charset': 'utf8'
     #     }
     self.sql_config = common.sql_config
     self.logger = common.log_init(__name__, 'oldmysql.log')
     self.logger.debug('hahahah')
Exemplo n.º 3
0
 def __init__(self, source, json_dict, job_category='', source_id=''):
     # with open(json_dict) as f:
     #     self.json_dict = json.load(f)
     # self.job_detail = self.json_dict
     #
     self.json_source = source
     if len(source_id) > 0:
         json_dict['id'] = source_id
         if source == 'cjol' and not source_id.startswith('J'):
             json_dict['id'] = 'J' + source_id
     self.job_detail = json_dict
     self.job_category = job_category
     # self.job_detail = self.json_dict['job_detail']
     # self.json_dict = json_dict
     # self.sql_config = {
     #         'host': "10.4.14.233",
     #         'user': "******",
     #         'passwd': "sv8VW6VhmxUZjTrU",
     #         'db': 'tuike',
     #         'charset': 'utf8'
     #     }
     self.sql_config = common.sql_config
     self.logger = common.log_init(__name__, 'oldmysql.log')
     self.logger.debug('hahahah')
Exemplo n.º 4
0
    def __init__(self,  position = '', id_number='', adviser_user=''):
        BaseFetch.__init__(self)

        # 确定是否是调试模式
        ### DEBUG 最后一个参数标示 debug
        if len(sys.argv) >= 5:
            if sys.argv[4] == "debug":
                self.debug = True
            else:
                self.debug = False
        else:
            self.debug = False

        # 选取合适的 cookie 文件
        if position == 'gz':
            ppp = '广州'
        elif position == 'sz':
            ppp = '深圳'
        elif position == 'bj':
            ppp = '北京'
        elif position == 'hz':
            ppp = '杭州'
        elif position == 'sh':
            ppp = '上海'
        else:
            ppp = '%'

        self.ctmname=''
        self.username=''
        self.password=''
        self.rp = Rdsreport()  # 将这个放在前面,避免 redispipe 初始化的时候,将logger 的保存位置改到别的地方
        acc = libaccount.Manage(source='51job', option='buy', location=ppp)
        # init other log
        with open(json_config_path) as f:
            ff = f.read()
        logger = logging.getLogger(__name__)
        log_dict = json.loads(ff)
        log_dict['loggers'][""]['handlers'] = ["file", "stream", "buy", "error"]
        logging.config.dictConfig(log_dict)
        logging.debug('hahahahha')

        self.host=r'ehire.51job.com'
        self.domain='51job.com'
        self.module_name='51jobdown'
        self.init_path()
        self.login_wait=300

        self.refer=''
        self.headers={
            'Host':self.host,
            'User-Agent': 'Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0',
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
        }

        self.login_type = 2
        self.login_at = None
        self.logout_at = None
        self.need_login_tags=['<td colspan="2" class="loginbar">',
                              '<input type="button" onclick="loginSubmit']

        self.resume_tags=['<div id="divResume"><style>','简历编号', '简历信息']
        self.login_success_tag=[]

        self.adviser_user = adviser_user
        self.id_number=id_number
        self.position = position
        self.inuse_taskfpath=''

        #用于记录执行号段任务的参数,起始/结束/当前
        self.start_num=0
        self.end_num=0
        self.current_num=self.start_num
        self.maxsleeptime = 5
        self.logger = common.log_init(__name__, '51buy2.log')
        username1 = acc.uni_user()
        self.logger.info('select username is {}'.format(username1))
        self.has_cookie = True
        if username1:
            self.username = username1
            logging.info('cjol buy select username is {}'.format(self.username))
            self.headers['Cookie'] = acc.redis_ck_get(self.username)
        else:
            logging.error('no avail login cookie for 51down')
            self.send_mails('Warining, no account for 51down', 'no avail login cookie for 51down')
            print '没有已经登陆的 51job cookie文件'
            self.has_cookie = False
            # quit()  # 这里不退出,在runwork那里才 return something
        print 'id num is {}'.format(id_number)
        print 'position is {}'.format(position)
        logging.info('trying to buy id {}, position is {}'.format(self.id_number, self.position))
Exemplo n.º 5
0
import time
import common
import logging, logging.config
from prettytable import PrettyTable
import sys
reload(sys)
sys.setdefaultencoding('utf8')

# logger = logging.getLogger('')
# logger.setLevel(logging.DEBUG)
# ch = logging.StreamHandler()
# ch.setLevel(logging.INFO)
# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# ch.setFormatter(formatter)
# logger.addHandler(ch)
logger = common.log_init(__name__, 'statmo.log')

# 初始化一个key 用来存储一个 fun_action,带时间,带次数,
# 检查时间超过半个小时,删除key,把次数,添加到邮件里面 (只对100 的有用)
func_dict = {}

def get_con():
    con = MySQLdb.connect(**common.sql_config)
    return con

def calculate_time():
    now = time.mktime(datetime.datetime.now().timetuple())-60*2
    print now
    result = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now))
    print result
    res2 = datetime.datetime.now() - datetime.timedelta(minutes=120) # 2 个小时
Exemplo n.º 6
0
    def __init__(self, position='', id_number='', adviser_user=''):
        BaseFetch.__init__(self)

        # 确定是否是调试模式
        ### DEBUG 最后一个参数标示 debug
        if len(sys.argv) >= 5:
            if sys.argv[4] == "debug":
                self.debug = True
            else:
                self.debug = False
        else:
            self.debug = False

        # 选取合适的 cookie 文件
        if position == 'gz':
            ppp = '广州'
        elif position == 'sz':
            ppp = '深圳'
        elif position == 'bj':
            ppp = '北京'
        elif position == 'hz':
            ppp = '杭州'
        elif position == 'sh':
            ppp = '上海'
        else:
            ppp = '%'

        self.ctmname = ''
        self.username = ''
        self.password = ''
        self.rp = Rdsreport(
        )  # 将这个放在前面,避免 redispipe 初始化的时候,将logger 的保存位置改到别的地方
        acc = libaccount.Manage(source='51job', option='buy', location=ppp)
        # init other log
        with open(json_config_path) as f:
            ff = f.read()
        logger = logging.getLogger(__name__)
        log_dict = json.loads(ff)
        log_dict['loggers'][""]['handlers'] = [
            "file", "stream", "buy", "error"
        ]
        logging.config.dictConfig(log_dict)
        logging.debug('hahahahha')

        self.host = r'ehire.51job.com'
        self.domain = '51job.com'
        self.module_name = '51jobdown'
        self.init_path()
        self.login_wait = 300

        self.refer = ''
        self.headers = {
            'Host': self.host,
            'User-Agent':
            'Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0',
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
        }

        self.login_type = 2
        self.login_at = None
        self.logout_at = None
        self.need_login_tags = [
            '<td colspan="2" class="loginbar">',
            '<input type="button" onclick="loginSubmit'
        ]

        self.resume_tags = ['<div id="divResume"><style>', '简历编号', '简历信息']
        self.login_success_tag = []

        self.adviser_user = adviser_user
        self.id_number = id_number
        self.position = position
        self.inuse_taskfpath = ''

        #用于记录执行号段任务的参数,起始/结束/当前
        self.start_num = 0
        self.end_num = 0
        self.current_num = self.start_num
        self.maxsleeptime = 5
        self.logger = common.log_init(__name__, '51buy2.log')
        username1 = acc.uni_user()
        self.logger.info('select username is {}'.format(username1))
        self.has_cookie = True
        if username1:
            self.username = username1
            logging.info('cjol buy select username is {}'.format(
                self.username))
            self.headers['Cookie'] = acc.redis_ck_get(self.username)
        else:
            logging.error('no avail login cookie for 51down')
            self.send_mails('Warining, no account for 51down',
                            'no avail login cookie for 51down')
            print '没有已经登陆的 51job cookie文件'
            self.has_cookie = False
            # quit()  # 这里不退出,在runwork那里才 return something
        print 'id num is {}'.format(id_number)
        print 'position is {}'.format(position)
        logging.info('trying to buy id {}, position is {}'.format(
            self.id_number, self.position))
Exemplo n.º 7
0
# encoding: utf8

import requests
import logging, logging.config
import time
import common, json, os, MySQLdb
import timeit
import redispipe
import random
import sys
from prettytable import PrettyTable
import datetime
import re

rp = redispipe.Rdsreport()
common.log_init(__name__, 'test.log')
web_dict = {
    'translate': {
        'url': 'http://123.58.136.243:8087/translator',
        'data': {},
        'op': 'get'
    },
    'segmenter': {
        'url': 'http://123.58.136.243:8087/segmenter',
        'data': {
            'text': '没时间解释了,赶紧上车'
        },
        'op': 'get'
    },
    'worktile_task': {
        'url': 'http://123.58.128.216:8086/task/',
Exemplo n.º 8
0
import time
import common
import logging, logging.config
from prettytable import PrettyTable
import sys
reload(sys)
sys.setdefaultencoding('utf8')

# logger = logging.getLogger('')
# logger.setLevel(logging.DEBUG)
# ch = logging.StreamHandler()
# ch.setLevel(logging.INFO)
# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# ch.setFormatter(formatter)
# logger.addHandler(ch)
logger = common.log_init(__name__, 'statmo.log')

# 初始化一个key 用来存储一个 fun_action,带时间,带次数,
# 检查时间超过半个小时,删除key,把次数,添加到邮件里面 (只对100 的有用)
func_dict = {}


def get_con():
    con = MySQLdb.connect(**common.sql_config)
    return con


def calculate_time():
    now = time.mktime(datetime.datetime.now().timetuple()) - 60 * 2
    print now
    result = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now))
Exemplo n.º 9
0
# encoding: utf8

import requests
import logging, logging.config
import time
import common, json, os, MySQLdb
import timeit
import redispipe
import random
import sys
from prettytable import PrettyTable
import datetime
import re

rp = redispipe.Rdsreport()
common.log_init(__name__, 'test.log')
web_dict = {
    'translate': {'url': 'http://123.58.136.243:8087/translator',
                  'data': {},
                  'op': 'get'},
    'segmenter': {'url': 'http://123.58.136.243:8087/segmenter',
                 'data': {'text': '没时间解释了,赶紧上车'},
                 'op': 'get'},
    'worktile_task': {'url': 'http://123.58.128.216:8086/task/',
                      'data': {'q': 'asdfa', 'from': '1223', 'size': 10},
                      'op': 'get'},
    'transfer_51': {'url': 'http://123.58.128.216:8086/job51/',
                    'data': {'page': random.choice(range(1, 10)),
                             'area': random.choice([u'广州', u'深圳', u'北京', u'上海']),
                             'degree': u'本科',
                             'keyword': random.choice(['java', 'php', 'ios']),