Exemplo n.º 1
0
def get_arg_int(key, default=None):
    value = request.args.get(key, default)
    if str(value).lstrip('-').isdigit():
        return int(value)
    abort(
        HTTPStatus.BadRequest,
        **make_resp(status=APIStatus.BadRequest, msg='参数 %s 不是 int' % (key, )))
Exemplo n.º 2
0
def get_arg(key, default=None):
    """获取get参数"""
    value = request.args.get(key, default)
    if value is not None:
        return value
    abort(HTTPStatus.BadRequest,
          **make_resp(status=APIStatus.BadRequest, msg='缺少请求参数%s' % key))
Exemplo n.º 3
0
def get_payload():
    """获取post参数"""
    payload = request.json
    if payload:
        return payload_escape(payload)
    abort(HTTPStatus.BadRequest,
          **make_resp(status=APIStatus.BadRequest, msg='缺少请求数据'))
Exemplo n.º 4
0
def check_jobs_list(params):

    try:
        params["job_name"] = str(params.get("job_name", ''))
        params["region"] = str(params.get("region") or '')
        params["time_scale"] = int(params.get("time_scale") or 0)
        params["page"] = int(params.get("page") or 1)

        return params

    except Exception as e:
        log.error('查询职位列表出现错误 [Error: %s]' % e)
        abort(
            HTTPStatus.InternalServerError,
            **make_resp(status=APIStatus.InternalServerError,
                        msg='查询职位列表出现错误'))
Exemplo n.º 5
0
 def get():
     params = get_all_arg()
     params["search_name"] = str(params.get("search_name") or "python")
     params["region"] = str(params.get("region") or "全国")
     result = get_job_detail_result(params["search_name"], params["region"])
     return make_resp(status=APIStatus.Ok, data=result)
Exemplo n.º 6
0
 def get():
     params = get_all_arg()
     params["search_name"] = str(params.get("search_name") or "python")
     result = job_count_spider(params["search_name"])
     return make_resp(status=APIStatus.Ok, data=result)
Exemplo n.º 7
0
 def get():
     params = get_all_arg()
     params = check_jobs_list(params)
     result = boss_spider(params)
     return make_resp(status=APIStatus.Ok, data=result, count=999999)