def get_outerPositionId(): referer_url = 'https://easy.lagou.com/position/multiChannel/myOnlinePositions.htm?pageNo=1' url = 'https://easy.lagou.com/parentPosition/multiChannel/myOnlinePositions.json' data = {'pageNo': 1} header = get_code_token(url=referer_url) r = form_post(url=url, headers=header, data=data, remark='职位类型升级', rd='royliu') outerPositionId = r['content']['data']['parentPositionVOs'][0][ 'positions']['outerPositionId'] return outerPositionId
def can_new_clean(): url = "https://easy.lagou.com/can/new/clean.json" data = {"stages": "NEW", "days": "30"} header = get_code_token( "https://easy.lagou.com/can/index.htm?can=true&stage=NEW&needQueryAmount=true&newDeliverTime=0" ) remark = "清理30天内的新简历" return form_post(url=url, data=data, headers=header, remark=remark) # login("00852", 20181205) # can_new_index() # can_new_clean()
def move_to_communicated(positionId, resumeOwnerId): url = 'https://easy.lagou.com/settings/template/in_temp.json?positionId=' + str( positionId) refer_listofcandidates_url = "https://easy.lagou.com/can/index.htm" listofcandidates_header = get_code_token(refer_listofcandidates_url) get_requests(url=url, headers=listofcandidates_header) toStageLink_url = 'https://easy.lagou.com/can/batch/toStageLink.json' toStageLink_data = {"resumeIds": resumeOwnerId} return form_post(url=toStageLink_url, data=toStageLink_data, headers=listofcandidates_header, remark='移动到待沟通')
def add_risk_labels_by_company(companyId, labelIds): url = 'http://home.lagou.com/audit/companyApprove/addRiskLabelsByCompany.json' header = get_header(url='http://home.lagou.com/index.html') data = { 'companyId': companyId, 'labelIds': labelIds, } remark = '贴风险标签' return form_post(url=url, headers=header, data=data, remark=remark, rd='王豪')
def move_hire(): refer_listofcandidates_url = "https://easy.lagou.com/can/index.htm" listofcandidates_header = get_code_token(refer_listofcandidates_url) newlist_url = "https://easy.lagou.com/can/new/list.json" newlist_data = { "pageNo": 0, "stage": "INTERVIEW", "can": "true", "needQueryAmount": "true", "newDeliverTime": 0 } r = form_post(newlist_url, newlist_data, listofcandidates_header) positionId = r['content']['rows'][0]['positionId'] resumeOwnerId = r['content']['rows'][0]['id'] url = 'https://easy.lagou.com/settings/template/in_temp.json?positionId=' + str( positionId) get_requests(url, listofcandidates_header) toStageOffer_url = 'https://easy.lagou.com/can/batch/toStageOffer.json' toStageOffer_data = {"resumeIds": resumeOwnerId} r = form_post(toStageOffer_url, toStageOffer_data, listofcandidates_header)
def recover_sub_account(userId): ''' 一键恢复无效子账号功能, 前置条件是公司的合同已被停用,再添加新的合同 :param userId: int, 子账号用户id :return: string, 删除结果 ''' # refer_queryAcount_url = "https://easy.lagou.com/subAccount/queryAcount/index.htm" recoverAcount_url = "https://easy.lagou.com/subAccount/recoverSubAccount.json" recoverAcount_data = {"userIds": userId} recoverAcount_header = {} remark = "验证一键恢复无效子账号功能是否ok" return form_post(url=recoverAcount_url, data=recoverAcount_data, headers=recoverAcount_header, remark=remark)
def post_position(sum, **kwargs): ''' 批量发布职位 :param sum: 发布职位个数 :return: 发布职位的请求 ''' reslist = [] if bool(kwargs.get('workAddressId')) == False: addressId = get_Address() else: addressId = kwargs.get('workAddressId') firstType = kwargs.get("firstType", "市场|商务类") positionType = kwargs.get("positionType", "市场|营销") positionThirdType = kwargs.get("positionThirdType", "市场营销") positionName = kwargs.get("positionName", "高级市场营销经理") for i in range(sum): refer_createPosition_url = "https://easy.lagou.com/position/multiChannel/createPosition.htm" Position_header = get_code_token(refer_createPosition_url) createPosition_url = "https://easy.lagou.com/parentPosition/multiChannel/create.json" createPosition_data = {**{'isSchoolJob': '0', 'channelTypes': 'LAGOU', 'department': '111', 'jobNature': '全职', 'salaryMin': '11', 'salaryMax': '12', 'education': '不限', 'workAddressId': addressId, 'positionBrightPoint': '11111', 'workYear': '3-5年', 'channels': '108', 'recommend': True, 'extraInfor': '[{"labels":[{"id":"1","name":"电商"}]}]', 'positionDesc': '<p>111111111111111111111111111111111111111111111</p>', 'labels': '[{"id":"1","name":"电商"}]', 'parentExtraInfo': '{}', "useEnergyCard": False}, "firstType": firstType, "positionType": positionType, "positionThirdType": positionThirdType, "positionName": positionName} remark = "批量发布职位" + str(sum) + "个成功" r = form_post( url=createPosition_url, data=createPosition_data, headers=Position_header, remark=remark) reslist.append(r) return reslist
def online_positionId_outerPositionId(): refer_offlinePosition_url = "https://easy.lagou.com/position/multiChannel/myOnlinePositions.htm?pageNo=1" Position_header = get_code_token(refer_offlinePosition_url) myonlinepostions_url = "https://easy.lagou.com/parentPosition/multiChannel/myOnlinePositions.json" myonlinepostions_data = {"pageNo": 1} remark = "获取下线职位的职位id" r = form_post(url=myonlinepostions_url, data=myonlinepostions_data, headers=Position_header, remark=remark, rd='royliu') try: positionId = r['content']['data']['parentPositionVOs'][0]['positions'][0]['positionId'] outerPositionId = r['content']['data']['parentPositionVOs'][0]['positions'][0]['outerPositionId'] except KeyError: positionId = 0 outerPositionId = 0 return positionId, outerPositionId
def calling(cUserid): calling_url = 'https://easy.lagou.com/phonecall/getVirtualNum.json' calling_header = get_code_token('https://easy.lagou.com/talent/index.htm') calling_data = {'cUserId': cUserid} s = form_post(url=calling_url, headers=calling_header, data=calling_data, remark=u'直call大咖') # if s['message'] == u'成功': # print (u'virtualPhone:' ,s['content']['data']['result']['virtualPhone']) return s # print(calling(cUserid))
def post_position_city(sum, addressId): ''' 批量发布职位 :param sum: 发布职位个数 :return: 发布职位的请求 ''' reslist = [] login('00852', 20181205) for i in range(sum): position_info = postype[random.randint(0, 8)] firstType = position_info['firstType'] positionType = position_info['positionType'] positionThirdType = position_info['positionThirdType'] positionName = position_info['positionName'] refer_createPosition_url = "https://easy.lagou.com/position/multiChannel/createPosition.htm" Position_header = get_code_token(refer_createPosition_url) createPosition_url = "https://easy.lagou.com/parentPosition/multiChannel/create.json" createPosition_data = { **{ 'isSchoolJob': '1', 'channelTypes': 'LAGOU', 'department': '111', 'jobNature': '全职', 'salaryMin': '11', 'salaryMax': '12', 'education': '不限', 'workAddressId': addressId, 'positionBrightPoint': '11111', 'workYear': '应届毕业生', 'channels': '108', 'recommend': True, 'extraInfor': '[{"labels":[{"id":"1","name":"电商"}]}]', 'positionDesc': '<p>111111111111111111111111111111111111111111111</p>', 'labels': '[{"id":"1","name":"电商"}]', 'parentExtraInfo': '{}', "useEnergyCard": False }, "firstType": firstType, "positionType": positionType, "positionThirdType": positionThirdType, "positionName": positionName + str(random.randint(10, 110)) } remark = "批量发布职位" + str(sum) + "个成功" r = form_post(url=createPosition_url, data=createPosition_data, headers=Position_header, remark=remark) reslist.append(r) return reslist
def add_sub_account(userId_list): ''' 增加子账号功能 :param userId: int, 子账号用户id :return: int, 请求返回结果的用户id ''' for userId in userId_list: refer_queryAcount_url = "https://easy.lagou.com/subAccount/queryAcount/index.htm" queryAcount_url = "https://easy.lagou.com/subAccount/addAcount.json" queryAcount_data = {"userId": userId} queryAcount_header = get_header(refer_queryAcount_url) remark = "验证增加子账号功能是否ok" r = form_post(url=queryAcount_url, data=queryAcount_data, headers=queryAcount_header, remark=remark) return r
def remove_sub_account(userId_list): ''' 移除子账号功能 :param userId: int, 子账号用户id :return: string, 删除结果 ''' for userId in userId_list: # refer_queryAcount_url = "https://easy.lagou.com/subAccount/queryAcount/index.htm" removeAcount_url = "https://easy.lagou.com/subAccount/delAcount.json" removeAcount_data = {"userId": userId} removeAcount_header = {} remark = "验证移除子账号功能是否ok" r = form_post(url=removeAcount_url, data=removeAcount_data, headers=removeAcount_header, remark=remark) return r
def offineposition(id): offine_url = 'https://easy.lagou.com/position/offlinePosition.json' offine_header = get_code_token( 'https://easy.lagou.com/position/multiChannel/myOnlinePositions.htm') offine_data = {'positionId': id} s = form_post(url=offine_url, headers=offine_header, data=offine_data, remark='下线职位', rd='royliu') return s # print(getonlinepositionlimit())
def move_to_stageoffer(positionId, resumeOwnerId): refer_listofcandidates_url = "https://easy.lagou.com/can/index.htm" listofcandidates_header = get_code_token(refer_listofcandidates_url) url = 'https://easy.lagou.com/settings/template/in_temp.json?positionId=' + str( positionId) get_requests(url=url, headers=listofcandidates_header) stage_url = 'https://easy.lagou.com/can/batch/toStageOffer.json' stage_data = {"resumeIds": resumeOwnerId} r = form_post(url=stage_url, headers=listofcandidates_header, data=stage_data, remark='录用') return r
def can_new_list(stage): url = "https://easy.lagou.com/can/new/list.json" header = get_code_token( f'https://easy.lagou.com/can/new/index.htm?can=true&stage={stage}&needQueryAmount=true&newDeliverTime=0&pageNo=1&subStage=' ) data = { "stage": stage, "pageNo": 1, "can": True, "needQueryAmount": True, "newDeliverTime": 0 } remark = "获取简历列表(新简历或初筛)" return form_post(url=url, data=data, headers=header, remark=remark)
def can_new_createFilter(): url = "https://easy.lagou.com/can/new/createFilter.json" header = get_code_token( "https://easy.lagou.com/can/index.htm?stage=NEW&pageNo=1&can=true&needQueryAmount=true&newDeliverTime=0&plusTypes=2%2C1&channels=108" ) data = { "name": "1", "newDeliverTime": "0", "channels": "108", "plusTypes": "2,1", "famousCompany": "0", "stages": "NEW" } remark = "创建候选人筛选器" return form_post(url=url, data=data, headers=header, remark=remark)
def passPersonApprove(): referer_queryPerson_home_url = "https://home.lagou.com/#/h_review/company" queryPerson_url = "https://home.lagou.com/audit/personApprove/queryPersonByParam.json" queryPerson_data = { "startPage": 1, "auditor": "", "searchParam": "", "searchContent": "", "pageSize": 1, "approveTimeSort": "desc", "auditStatusType": "wait" } queryPerson_header = get_header(referer_queryPerson_home_url) remark = "验证home后台-审核中心-倒序获取招聘者的id是否成功" queryPerson_res = form_post(url=queryPerson_url, data=queryPerson_data, headers=queryPerson_header, remark=remark) try: personCheckId = queryPerson_res['data']['pageData'][0]['personCheck'][ 'id'] companyId = queryPerson_res['data']['pageData'][0]['companyCheckVo'][ 'companyId'] userId = queryPerson_res['data']['pageData'][0]['personCheckVo'][ 'userId'] except KeyError: personCheckId, companyId, userId = None, None, None passPersonApprove_url = "https://home.lagou.com/audit/personApprove/passPersonApprove.json" passPersonApprove_data = {"personCheckId": personCheckId} remark = "验证home后台-审核中心-个人认证-审核招聘者是否成功" return form_post(url=passPersonApprove_url, data=passPersonApprove_data, headers=queryPerson_header, remark=remark), companyId, userId
def educationExperience(): basicMain_html = 'https://www.lagou.com/resume/perfectresume.html' edu_header = get_code_token(basicMain_html) edu_url = 'https://www.lagou.com/educationExperience/save.json' edu_data = { 'schoolName': '清华大学', 'education': '本科', 'professional': '计算机科学与技术', 'startDate': '2009', 'endDate': '2013' } return form_post(url=edu_url, headers=edu_header, data=edu_data, remark='教育经历')
def open_product(companyId, userId, contractNo): headers = get_header('https://home.lagou.com/') url = 'https://home.lagou.com/crm/valueadded/product/open.json' data = { 'templateId': 90, 'num': 10, 'companyId': companyId, 'contractNo': contractNo, 'userId': userId, 'startTimeStr': '2019-05-14', 'endTimeStr': '2021-05-31', 'upgrade': False } remark = "开启合同" return form_post(url=url, data=data, headers=headers, remark=remark, rd='杨振宇')['success']
def Refreshed(second): ''' 18版合同“一键刷新” 刷新所有职位,包括已经刷新过一次的 :return: ''' login("00852", "20181205") position_url = 'https://easy.lagou.com/parentPosition/multiChannel/myOnlinePositions.json' position_header = get_code_token( 'https://easy.lagou.com/position/multiChannel/myOnlinePositions.htm') s = form_post(url=position_url, headers=position_header, data={'pageNo': 1}, remark='获取职位id') positionId = s['content']['data']['parentPositionIds'] refresh_url = "https://easy.lagou.com/parentPosition/multiChannel/statistics.json" refresh_header = get_code_token( "https://easy.lagou.com/position/my_online_positions.htm?pageNo=1") refresh_data = {'needCandidateNum': 'true', 'parentIds': positionId} print(refresh_header) jsonobject = form_post(url=refresh_url, headers=refresh_header, data=refresh_data, remark='一键刷新职位') a = jsonobject.get("message") print(a) if a == "操作成功": assert_equal("操作成功", a, "一键刷新成功", "一键刷新失败") else: time.sleep(second) jsonobject = form_post(url=refresh_url, headers=refresh_header, data=refresh_data, remark='刷新职位') assert_equal("操作成功", a, "一键刷新成功", "一键刷新失败")
def company_auth(): # com_header = get_header("https://easy.lagou.com/dashboard/index.htm?from=c_index")headers=com_header get_requests("https://easy.lagou.com/bstatus/auth/index.htm") com_step1_url = "https://hr.lagou.com/corpCenter/company/auth/step1.html" auth_file_url = "https://hr.lagou.com/corpCenter/company/auth/file.json" auth_file_data = { "fileUrl": "i/audio1/M00/01/C5/CgHIk1wQzSaAcR09AAqex8SeJls235.JPG" } auth_file_header = get_code_token(com_step1_url) remark = "上传营业执照" return form_post(url=auth_file_url, data=auth_file_data, headers=auth_file_header, remark=remark, rd='王豪')
def interview_new_list(range, ip_port=None): url = 'https://easy.lagou.com/interview/new/list.json' header = get_header(url='https://easy.lagou.com/interview/new/index.htm?', ip_port=ip_port) data = { 'sign': 'false', 'notInterview': 'false', 'pageSize': 20, 'pageNo': 1, 'range': range } return form_post(url=url, headers=header, data=data, remark='统计面试日程', ip_port=ip_port)
def register(countryCode, phone): c_register_html = 'https://passport.lagou.com/register/register.html?from=c' register_url = 'https://passport.lagou.com/register/register.json' register_data = { 'isValidate': 'true', 'phone': phone, 'phoneVerificationCode': '049281', 'challenge': 111, 'type': 0, 'countryCode': countryCode } register_header = get_code_token(c_register_html) return form_post(url=register_url, headers=register_header, data=register_data, remark='注册')
def get_interview(access_token, resume_id, **kwargs): link_phone = kwargs.get('link_phone', '18500000000') link_man = kwargs.get('link_man', fake.name()) interview_address = kwargs.get('interview_address', fake.address()) interview_time = kwargs.get('interview_time', int(round(time.time() * 1000))) url = f'https://open.lagou.com/v1/resume/interview?access_token={access_token}' data = { 'resume_id': resume_id, 'link_phone': link_phone, 'link_man': link_man, 'interview_address': interview_address, 'interview_time': interview_time } remark = '邀约面试' return form_post(url=url, data=data, remark=remark, rd='张文超')
def submit(updateCompanyShortName): submit_url = "https://hr.lagou.com/corpCenter/hr/auth/file/submit.json" submit_data = { "authenticationFileUrl": "i/audio1/M00/01/C5/CgHIk1wQzSaAcR09AAqex8SeJls235.JPG", "holdIDCardPhotoUrl": "i/audio1/M00/01/C5/CgHIk1wQzR6AS8YlAAC5OWWN-yU456.JPG", "updateCompanyShortName": updateCompanyShortName } step2_url = 'https://hr.lagou.com/corpCenter/openservice/step2.html' submit_header = get_code_token(step2_url) remark = "验证B端提交招聘者审核是否成功" return form_post(url=submit_url, data=submit_data, headers=submit_header, remark=remark)
def isprivilige(): # 返回false为在线职位公司,返回true为特权职位 s = form_post( remark='判断是否特权职位', url= 'https://easy.lagou.com/userGoodsRecord/initPriviligePositionPage.json', headers=get_code_token( 'https://easy.lagou.com/position/multiChannel/myOnlinePositions.htm' ), data={ 'pageNo': 1, 'pageSize': 1 }) if s['message'] == '该公司不是特权职位公司,不允许请求初始化数据': return False else: return True
def basicMain(userIdentity): basicMain_html = 'https://www.lagou.com/resume/perfectresume.html' basicMain_url = 'https://www.lagou.com/resume/basicMain.json' basicMain_header = get_code_token(basicMain_html) basicMain_data = { 'name': 'zyq', 'birthday': '1995.10', 'sex': '男', 'email': '*****@*****.**', 'userIdentity': userIdentity, 'liveCity': '北京', 'joinWorkTime': '2011.05' } return form_post(url=basicMain_url, headers=basicMain_header, data=basicMain_data, remark='基本信息')
def sendResume(positionId): resumeId = get_resumeId(0) url = 'https://passport.lagou.com/grantServiceTicket/grant.html' get_header(url) sendResume_html = 'https://www.lagou.com/jobs/{}.html'.format(positionId) sendResume_url = 'https://www.lagou.com/mycenterDelay/deliverResumeBeforce.json' sendResume_header = get_code_token(sendResume_html) sendResume_data = { 'positionId': str(positionId), 'type': 1, 'resumeId': resumeId, 'force': 'true' } return form_post(url=sendResume_url, headers=sendResume_header, data=sendResume_data, remark='发简历')
def saveHR(companyFullName, userName, resumeReceiveEmail, userPosition='HR'): step1_url = 'https://hr.lagou.com/corpCenter/openservice/step1.html' saveHR_url = "https://hr.lagou.com/corpCenter/openservice/saveHR.json" saveHR_data = { "userAvatar": "i/image/M00/1D/9B/CgqCHl7iFKuAdRWmAADtZK4uNm0834.jpg", "userName": userName, "userPosition": userPosition, "companyFullName": companyFullName, "resumeReceiveEmail": resumeReceiveEmail } saveHR_header = get_code_token(step1_url) remark = "验证上传B端用户信息是否成功" return form_post(url=saveHR_url, data=saveHR_data, headers=saveHR_header, remark=remark, rd='王豪')
def b_register(phone, countryCode): b_register_url = 'https://passport.lagou.com/register/register.html?from=b' register_url = "https://passport.lagou.com/register/register.json" register_data = { "isValidate": "true", "phone": phone, "phoneVerificationCode": "049281", "challenge": 111, "type": 1, "countryCode": countryCode } register_header = get_code_token(b_register_url) remark = "验证B端注册" return form_post(url=register_url, data=register_data, headers=register_header, remark=remark)