From 67d8d454849bb2038d78b03554ddd6ea34f42497 Mon Sep 17 00:00:00 2001 From: JasonYANG170 Date: Fri, 16 Aug 2024 20:54:57 +0800 Subject: [PATCH] V3.0:Support new platforms --- README.md | 2 +- UserDefined.py | 38 +++++++--- bosszhipin.py | 113 +++++++++++++++++++++++++++++ notify.py | 28 ++++++-- shixiseng.py | 188 ++++++++++++++++++++++++++----------------------- system.py | 6 +- yizhanchi.py | 181 ++++++++++++++++++++++++----------------------- 7 files changed, 362 insertions(+), 194 deletions(-) create mode 100644 bosszhipin.py diff --git a/README.md b/README.md index b22fecd..76015c5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ (除Linkedin外推荐使用中国IP部署) ## 支持平台 - ✅ 实习僧 -- ✅ 翼展翅 +- ✅ 易展翅 - 🚧 Boss直聘 - 🚧 51 Job - 🚧 Linkedin diff --git a/UserDefined.py b/UserDefined.py index 79f9cde..87bb73f 100644 --- a/UserDefined.py +++ b/UserDefined.py @@ -16,7 +16,7 @@ deviceName='HUAWEI' # 是否启用实习僧 shixiseng_state = 1 yizhanchi_state = 1 - +bosszhipin_state = 1 # --------------实习僧配置项-------------------- # 是否投递(不投递:0,投递优先在线简历:1,投递优先离线简历:2) shixiseng_poststate = 0 @@ -30,27 +30,26 @@ shixiseng_Search = { 'nature': "", # 类型:股份制企业|合伙企业 'scale': "", # 规模:50-150人|500-2000人 'ipo': "", # 融资:B轮|A轮 - 'k': "", # 岗位 * - 'degree': "", # 学历:大专|本科 + 'k': "嵌入式", # 岗位 * + 'degree': "大专|本科", # 学历:大专|本科 'emp_chance': "", # 空间:提供转正|面议 'intention': "", # 需求:校招|实习 'internship_duration': "", # 在岗时间:1个月|3个月以上 'days_per_week': "", # 工作时间:4天|1天 'payment_per_day': "" # 日薪:200-300|100以下 } -# --------------翼展翅配置项-------------------- -# 吐槽一下,翼展翅的数据非常的混乱,有小概率会出现城市筛选失效 +# --------------易展翅配置项-------------------- yizhanchi_poststate = 0 yizhanchi_city="" -yizhanchi_Token ="" +yizhanchi_Cookie ="" yizhanchi_Search = { - 'page_size': "50",#查询范围 * + 'page_size': "1000",#查询范围 * 'page': "1",#当前页面 * 'positiontype': "", 'minsalary': "",#最低工资 'maxsalary': "",#最高工资 'show_third_position': "", - 'keyword': "",#岗位 * + 'keyword': "软件 ",#岗位 * 'region_id': "", 'intern_time_id': "", 'intern_cycle_id': "", @@ -66,4 +65,27 @@ yizhanchi_Search = { 'port': "", 'region_type': "", 'sort': "" +} +# --------------Boss直聘配置项-------------------- +bosszhipin_poststate = 0 +bosszhipin_city="" +bosszhipin_Cookie ="" +bosszhipin_Search = { + 'scene': "1", + 'query': "嵌入式",#岗位 + 'city': "", + 'experience': "", + 'payType': "", + 'partTime': "", + 'degree': "", + 'industry': "", + 'scale': "", + 'stage': "", + 'position': "", + 'jobType': "", + 'salary': "", + 'multiBusinessDistrict': "", + 'multiSubway': "", + 'page': "1", + 'pageSize': "5000" } \ No newline at end of file diff --git a/bosszhipin.py b/bosszhipin.py new file mode 100644 index 0000000..5410782 --- /dev/null +++ b/bosszhipin.py @@ -0,0 +1,113 @@ + +import time +import requests +import json +from UserDefined import bosszhipin_city, bosszhipin_Search, bosszhipin_poststate, bosszhipin_Cookie +from system import Bosszhipin_CitylistUrl, Bosszhipin_SearchUrl, successful_deliveries, Bosszhipin_PostUrl + + +def run_bosszhipin_script(): + # 初始化计数器 + bosszhipin_findCount = 0 + bosszhipin_successCount = 0 + bosszhipin_errorCount = 0 + page = 1 + + # 请求头 + headers = { + 'User-Agent': "Mozilla/5.0 (Linux; Android 14; 21051182C Build/UQ1A.240105.004.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Safari/537.36 XWEB/1160117 MMWEBSDK/20240501 MMWEBID/1136 MicroMessenger/8.0.49.2685(0x28003145) WeChat/arm64 Weixin GPVersion/1 Android Tablet NetType/WIFI Language/zh_CN ABI/arm64", + 'Accept-Encoding': "gzip, deflate", + 'traceid': "F-e38d9aCURcZEnWMK", + 'x-requested-with': "XMLHttpRequest", + 'sec-fetch-site': "same-origin", + 'sec-fetch-mode': "cors", + 'sec-fetch-dest': "empty", + 'referer': "https://www.zhipin.com/", + 'accept-language': "zh-CN,zh-SG;q=0.9,zh;q=0.8,en-US;q=0.7,en;q=0.6,zh-HK;q=0.5", + 'Cookie': bosszhipin_Cookie # 将这个替换为你的实际cookie + } + + # 发送GET请求获取城市代码 + response = requests.get(Bosszhipin_CitylistUrl, headers=headers) + data = response.json() + + # 遍历 cityGroup 查找 name 为bosszhipin_city的城市对应的 code + city_code = None + for group in data['zpData']['cityGroup']: + for city in group['cityList']: + if city['name'] == bosszhipin_city: + city_code = city['code'] + break + if city_code is not None: + break + + print(f"{bosszhipin_city}的code值:", city_code) + try: + while True: + bosszhipin_Search['page'] = str(page) # 设置当前页码 + response = requests.get(Bosszhipin_SearchUrl, params=bosszhipin_Search, headers=headers) + data = response.json() + print(response.text) + item_list = data['zpData']['jobList'] + + if not item_list: + break + + print("------------Boss直聘-------------") + print("在Boss直聘平台找到以下岗位,即将为您投递:") + print("---------------------------------") + + for item in item_list: + bosszhipin_findCount += 1 + print(f"------------第{bosszhipin_findCount}家-------------") + encryptJobId = item.get('encryptJobId') + brandName = item.get('brandName') + jobName = item.get('jobName') + cityName = item.get('cityName') + salaryDesc = item.get('salaryDesc') + securityId = item.get('securityId') + welfareList=item.get('welfareList') + lid = item.get('lid') + + print(f"UUID: {encryptJobId}") + print(f"公司: {brandName}") + print(f"城市: {cityName}") + print(f"岗位: {jobName}") + print(f"薪资: {salaryDesc}") + print(f"福利: {welfareList }") + # print(f"HR刷新时间: {lid}") + print("-------------Result---------------") + if(bosszhipin_poststate==1): + bosszhipin_postparams = { + "securityId": securityId, + "jobId": encryptJobId, + "lid": lid + } + bosszhipin_Postresponse = requests.get(Bosszhipin_PostUrl, params=bosszhipin_postparams, headers=headers) + data = bosszhipin_Postresponse.json() + bosszhipin_bosszhipin_poststate = data['message'] + if bosszhipin_bosszhipin_poststate == '投递成功': + bosszhipin_successCount += 1 + delivery_info = { + "UUID": encryptJobId, + "公司": brandName, + "城市": cityName, + "岗位": jobName, + "薪资": salaryDesc, + "福利": welfareList, + } + successful_deliveries.append(delivery_info) + else: + bosszhipin_errorCount += 1 + print("投递失败,请查看返回信息:") + print(bosszhipin_bosszhipin_poststate) + else: + print("您未开启Boss直聘投递,本次投递跳过") + # 投递逻辑在这里添加 + # time.sleep(10) + page += 1 # 页码自增 + except Exception as e: + print("Boss直聘Cookie失效,请更新Cookie") + print(f"错误信息: {e}") + + return bosszhipin_findCount, bosszhipin_successCount, bosszhipin_errorCount diff --git a/notify.py b/notify.py index 0f70a3c..98f9bce 100644 --- a/notify.py +++ b/notify.py @@ -1,7 +1,9 @@ # notify.py import requests import json -from UserDefined import poststate, UseResultPush, PushToken, shixiseng_state, yizhanchi_state +from UserDefined import poststate, UseResultPush, PushToken, shixiseng_state, yizhanchi_state, bosszhipin_state, \ + bosszhipin_poststate, yizhanchi_poststate, shixiseng_poststate +from bosszhipin import run_bosszhipin_script from system import ResultUrl, successful_deliveries from shixiseng import run_shixiseng_script from yizhanchi import run_yizhanchi_script @@ -16,6 +18,9 @@ def send_notifications(): notify_yizhanchi_findCount=0 notify_yizhanchi_successCount=0 notify_yizhanchi_errorCount=0 + notify_bosszhipin_findCount=0 + notify_bosszhipin_successCount=0 + notify_bosszhipin_errorCount=0 notify = "------------Notify---------------\n" if poststate in [1, 2]: if(shixiseng_state==1): @@ -34,18 +39,31 @@ def send_notifications(): notify_yizhanchi_successCount=yizhanchi_successCount errorCount=errorCount + yizhanchi_errorCount notify_yizhanchi_errorCount=yizhanchi_errorCount + if(bosszhipin_state==1): + bosszhipin_findCount, bosszhipin_successCount, bosszhipin_errorCount = run_bosszhipin_script() + findCount=findCount + bosszhipin_findCount + notify_bosszhipin_findCount=bosszhipin_findCount + successCount=successCount + bosszhipin_successCount + notify_bosszhipin_successCount=bosszhipin_successCount + errorCount=errorCount + bosszhipin_errorCount + notify_bosszhipin_errorCount=bosszhipin_errorCount notify += (f"今日总共找到{findCount}家公司\n" f"投递成功{successCount}份,投递失败{errorCount}份\n" f"-------------实习僧数据------------\n" f"找到{notify_shixiseng_findCount}家公司\n" f"投递成功{notify_shixiseng_successCount}份,投递失败{notify_shixiseng_errorCount}份\n") - if(notify_shixiseng_findCount!=0 and notify_shixiseng_successCount==0 and notify_shixiseng_errorCount==0): + if(shixiseng_poststate==0): notify += ( f"您未开启实习僧投递,本次投递跳过\n") - notify += ( f"-------------翼展翅数据------------\n" + notify += ( f"-------------易展翅数据------------\n" f"找到{notify_yizhanchi_findCount}家公司\n" f"投递成功{notify_yizhanchi_successCount}份,投递失败{notify_yizhanchi_errorCount}份\n") - if(notify_yizhanchi_findCount!=0 and notify_yizhanchi_successCount==0 and notify_yizhanchi_errorCount==0): - notify += ( f"您未开启翼展翅投递,本次投递跳过\n") + if(yizhanchi_poststate==0): + notify += ( f"您未开启易展翅投递,本次投递跳过\n") + notify += ( f"-------------Boss直聘数据------------\n" + f"找到{notify_bosszhipin_findCount}家公司\n" + f"投递成功{notify_bosszhipin_successCount}份,投递失败{notify_bosszhipin_errorCount}份\n") + if(bosszhipin_poststate==0): + notify += ( f"您未开启Boss直聘投递,本次投递跳过\n") try: notify += "---------成功投递的岗位信息-------\n" for delivery in successful_deliveries: diff --git a/shixiseng.py b/shixiseng.py index d2789bf..6751b38 100644 --- a/shixiseng.py +++ b/shixiseng.py @@ -8,7 +8,7 @@ def run_shixiseng_script(): shixiseng_successCount = 0 shixiseng_errorCount = 0 shixiseng_findCount = 0 - + page = 1 # 请求头 shixiseng_headers = { 'User-Agent': "sxsandroidapp/4.50.3", @@ -19,110 +19,118 @@ def run_shixiseng_script(): 'priority': "u=1, i", 'Cookie': shixiseng_Cookie } - + while True: + shixiseng_Search['p'] = str(page) # 设置当前页码 + # response = requests.get(yizhanchi_SearchUrl, params=yizhanchi_Search, headers=headers) # 发送 GET 请求 - shixiseng_SearchResponse = requests.get(shixiseng_SearchUrl, params=shixiseng_Search, headers=shixiseng_headers) + shixiseng_SearchResponse = requests.get(shixiseng_SearchUrl, params=shixiseng_Search, headers=shixiseng_headers) # print(shixiseng_SearchResponse.text) # 检查请求是否成功 - if shixiseng_SearchResponse.status_code == 200: - data = shixiseng_SearchResponse.json() + if shixiseng_SearchResponse.status_code == 200: + # data = shixiseng_SearchResponse.json() - try: - items = data['msg']['data'] + try: + data = shixiseng_SearchResponse.json() + items = data['msg']['data'] - uuid_list = [item['uuid'] for item in items] - company_list = [item['company'] for item in items] - job_list = [item['job'] for item in items] - salary_desc_list = [item['salary_desc'] for item in items] - attraction_list = [item['attraction'] for item in items] - city_list = [item['city'] for item in items] + if not items: + break - print("------------实习僧APP-------------") - print("在实习僧平台找到以下岗位,即将为您投递:") - print("---------------------------------") - for uuid, company, job, salary_desc, attraction, city in zip(uuid_list, company_list, job_list, salary_desc_list, attraction_list, city_list): - attraction_str = json.dumps(attraction, ensure_ascii=False) - shixiseng_Groupid = {'inuuid': uuid} + uuid_list = [item['uuid'] for item in items] + company_list = [item['company'] for item in items] + job_list = [item['job'] for item in items] + salary_desc_list = [item['salary_desc'] for item in items] + attraction_list = [item['attraction'] for item in items] + city_list = [item['city'] for item in items] - shixiseng_GroupResponse = requests.get(shixiseng_GroupUrl, params=shixiseng_Groupid, headers=shixiseng_headers) + print("------------实习僧-------------") + print("在实习僧平台找到以下岗位,即将为您投递:") + print("---------------------------------") - if shixiseng_GroupResponse.status_code == 200: - group_data = shixiseng_GroupResponse.json() + for uuid, company, job, salary_desc, attraction, city in zip(uuid_list, company_list, job_list, salary_desc_list, attraction_list, city_list): + attraction_str = json.dumps(attraction, ensure_ascii=False) + shixiseng_Groupid = {'inuuid': uuid} - try: - group_items = group_data['msg']['resume'] - deliver_able_list = [item['deliver_able'] for item in group_items] - group_list = [item['group_uuid'] for item in group_items] + shixiseng_GroupResponse = requests.get(shixiseng_GroupUrl, params=shixiseng_Groupid, headers=shixiseng_headers) - deliver_able_online = deliver_able_list[0] if len(deliver_able_list) > 0 else False - deliver_able_local = deliver_able_list[1] if len(deliver_able_list) > 1 else False - shixiseng_findCount=shixiseng_findCount + 1 - print(f"------------第{shixiseng_findCount}家-------------") - print(f"UUID: {uuid}") - print(f"公司: {company}") - print(f"城市: {city}") - print(f"岗位: {job}") - print(f"薪资: {salary_desc}") - print(f"福利: {attraction_str}") - print(f"在线简历投递状态: {'可投递' if deliver_able_online else '不可投递'}") - print(f"本地简历投递状态: {'可投递' if deliver_able_local else '不可投递'}") - print("-------------Result---------------") - usegroup = None # 初始化 usegroup + if shixiseng_GroupResponse.status_code == 200: + group_data = shixiseng_GroupResponse.json() - if (shixiseng_poststate == 1 and deliver_able_online) or (shixiseng_poststate == 2 and not deliver_able_local and deliver_able_online): - usegroup = group_list[0] - elif (shixiseng_poststate == 1 and not deliver_able_online and deliver_able_local) or (shixiseng_poststate == 2 and deliver_able_local): - usegroup = group_list[1] - elif (shixiseng_poststate == 0 and (deliver_able_online or deliver_able_local)): - usegroup = None - if usegroup: - shixiseng_Postpayload = json.dumps({ - "inuuid": uuid, - "group_uuid": usegroup, - "stype": "attach", - "report_time": "1周内", - "internship_time": "6个月以上", - "days": "5", - "mxa_data": "", - "position": "app_search_xgzw", - "deliver_type": 0 - }) + try: + group_items = group_data['msg']['resume'] + deliver_able_list = [item['deliver_able'] for item in group_items] + group_list = [item['group_uuid'] for item in group_items] - shixiseng_PostResponse = requests.post(shixiseng_PostUrl, data=shixiseng_Postpayload, headers=shixiseng_headers) - data = shixiseng_PostResponse.json() - shixiseng_shixiseng_poststate = data['msg']['cont'] - if shixiseng_shixiseng_poststate == 'success': - shixiseng_successCount += 1 - delivery_info = { - "UUID": uuid, - "公司": company, - "城市": city, - "岗位": job, - "薪资": salary_desc, - "福利": attraction_str, - # "投递来自": "在线简历" if usegroup == group_list[0] else "本地简历" - } - successful_deliveries.append(delivery_info) + deliver_able_online = deliver_able_list[0] if len(deliver_able_list) > 0 else False + deliver_able_local = deliver_able_list[1] if len(deliver_able_list) > 1 else False + shixiseng_findCount=shixiseng_findCount + 1 + print(f"------------第{shixiseng_findCount}家-------------") + print(f"UUID: {uuid}") + print(f"公司: {company}") + print(f"城市: {city}") + print(f"岗位: {job}") + print(f"薪资: {salary_desc}") + print(f"福利: {attraction_str}") + print(f"在线简历投递状态: {'可投递' if deliver_able_online else '不可投递'}") + print(f"本地简历投递状态: {'可投递' if deliver_able_local else '不可投递'}") + print("-------------Result---------------") + usegroup = None # 初始化 usegroup + + if (shixiseng_poststate == 1 and deliver_able_online) or (shixiseng_poststate == 2 and not deliver_able_local and deliver_able_online): + usegroup = group_list[0] + elif (shixiseng_poststate == 1 and not deliver_able_online and deliver_able_local) or (shixiseng_poststate == 2 and deliver_able_local): + usegroup = group_list[1] + elif (shixiseng_poststate == 0 and (deliver_able_online or deliver_able_local)): + usegroup = None + if usegroup: + shixiseng_Postpayload = json.dumps({ + "inuuid": uuid, + "group_uuid": usegroup, + "stype": "attach", + "report_time": "1周内", + "internship_time": "6个月以上", + "days": "5", + "mxa_data": "", + "position": "app_search_xgzw", + "deliver_type": 0 + }) + + shixiseng_PostResponse = requests.post(shixiseng_PostUrl, data=shixiseng_Postpayload, headers=shixiseng_headers) + data = shixiseng_PostResponse.json() + shixiseng_shixiseng_poststate = data['msg']['cont'] + if shixiseng_shixiseng_poststate == 'success': + shixiseng_successCount += 1 + delivery_info = { + "UUID": uuid, + "公司": company, + "城市": city, + "岗位": job, + "薪资": salary_desc, + "福利": attraction_str, + # "投递来自": "在线简历" if usegroup == group_list[0] else "本地简历" + } + successful_deliveries.append(delivery_info) + else: + shixiseng_errorCount += 1 + print(shixiseng_shixiseng_poststate) else: - shixiseng_errorCount += 1 - print(shixiseng_shixiseng_poststate) - else: - if shixiseng_poststate == 0: - print("您未开启实习僧投递,本次投递跳过") - elif shixiseng_poststate in [1, 2]: - - print("您已投递过该公司,本次投递跳过") - except KeyError as e: - print(f"获取投递状态数据失败: {e}") - else: - print(f"投递状态请求失败,HTTP状态码: {shixiseng_GroupResponse.status_code}") - except Exception as e: - print("实习僧中没有相关工作,请尝试放宽筛选") - print(f"错误信息: {e}") + if shixiseng_poststate == 0: + print("您未开启实习僧投递,本次投递跳过") + elif shixiseng_poststate in [1, 2]: - else: - print(f"请求失败,HTTP状态码: {shixiseng_SearchResponse.status_code}") + print("您已投递过该公司,本次投递跳过") + except KeyError as e: + print(f"获取投递状态数据失败: {e}") + else: + print(f"投递状态请求失败,HTTP状态码: {shixiseng_GroupResponse.status_code}") + except Exception as e: + print("实习僧中没有相关工作,请尝试放宽筛选") + print(f"错误信息: {e}") + + else: + print(f"请求失败,HTTP状态码: {shixiseng_SearchResponse.status_code}") + page += 1 return shixiseng_findCount, shixiseng_successCount, shixiseng_errorCount diff --git a/system.py b/system.py index 6841077..4834554 100644 --- a/system.py +++ b/system.py @@ -5,4 +5,8 @@ shixiseng_SearchUrl = "https://apigateway-h3.shixiseng.com/api/interns/v3.0/inte shixiseng_GroupUrl = "https://apigateway-h3.shixiseng.com/api/deliver/v3.0/deliver/options" shixiseng_PostUrl = "https://apigateway-h3.shixiseng.com/api/deliver/v3.0/deliver" yizhanchi_SearchUrl = "https://api.izhanchi.com/position/recommend/index" -yizhanchi_PostUrl = "https://api.izhanchi.com/user/send/" \ No newline at end of file +yizhanchi_PostUrl = "https://api.izhanchi.com/user/send/" +yizhanchi_CitylistUrl = "https://api.izhanchi.com/index/citylist" +Bosszhipin_CitylistUrl = "https://www.zhipin.com/wapi/zpCommon/data/cityGroup.json" +Bosszhipin_SearchUrl = "https://www.zhipin.com/wapi/zpgeek/search/joblist.json" +Bosszhipin_PostUrl = "https://www.zhipin.com/wapi/zpgeek/friend/add.json" \ No newline at end of file diff --git a/yizhanchi.py b/yizhanchi.py index 7163027..96f1831 100644 --- a/yizhanchi.py +++ b/yizhanchi.py @@ -1,109 +1,112 @@ import json import requests from datetime import datetime -from datetime import datetime -import time # 引入time模块 -from UserDefined import yizhanchi_Search, yizhanchi_city, deviceName, yizhanchi_poststate, \ - yizhanchi_Token -from system import yizhanchi_SearchUrl, yizhanchi_PostUrl, successful_deliveries - +import time +from UserDefined import yizhanchi_Search, yizhanchi_city, deviceName, yizhanchi_poststate, yizhanchi_Cookie +from system import yizhanchi_SearchUrl, yizhanchi_PostUrl, successful_deliveries, yizhanchi_CitylistUrl def run_yizhanchi_script(): - yizhanchi_findCount=0 - yizhanchi_successCount=0 - yizhanchi_errorCount=0 + yizhanchi_findCount = 0 + yizhanchi_successCount = 0 + yizhanchi_errorCount = 0 + page = 1 headers = { - 'User-Agent': "Mozilla/5.0 (Linux; Android 14;" +deviceName+" Build/UQ1A.240505.004.A1; wv) AppleWebKit/539.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Safari/537.36 XWEB/1170117 MMWEBSDK/20240301 MMWEBID/1139 MicroMessenger/8.0.49.2685(0x28003145) WeChat/arm64 Weixin GPVersion/1 Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android", + 'User-Agent': f"Mozilla/5.0 (Linux; Android 14; {deviceName} Build/UQ1A.240505.004.A1; wv) AppleWebKit/539.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Safari/537.36 XWEB/1170117 MMWEBSDK/20240301 MMWEBID/1139 MicroMessenger/8.0.49.2685(0x28003145) WeChat/arm64 Weixin GPVersion/1 Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android", 'Accept-Encoding': "gzip,compress,br,deflate", 'charset': "utf-8", - 'live-channel-id': "", 'content-type': "application/json; charset=UTF-8", - 'nonce': "0.9293333376178894", - 'share-user-id': "0", - 'promotion-user-id': "0", - 'from': "Android", - 'sign': "3k57a99c0ea677999434cc5a996b2578", - 'business-type': "", - 'page-route': "https://m.izhanchi.com/", - 'business-type-id': "0", - 'region': "zp", - 'Content-Type': "application/json; charset=UTF-8", - 'timestamp': str(int(time.time() * 1000)), # 使用当前时间戳 - 'campus-channel-type': "0", - 'campus-channel-id': "0", - 'token': yizhanchi_Token, + 'timestamp': str(int(time.time() * 1000)), + 'Cookie': yizhanchi_Cookie, 'appkey': "yizhanchi", 'version': "H5_3.3.3", - 'Origin': "https://m.izhanchi.com", - 'X-Requested-With': "com.tencent.mm", - 'Sec-Fetch-Site': "same-site", - 'Sec-Fetch-Mode': "cors", - 'Sec-Fetch-Dest': "empty", 'Referer': "https://m.izhanchi.com/", 'Accept-Language': "zh-CN,zh-SG;q=0.9,zh;q=0.8,en-US;q=0.7,en;q=0.6,zh-HK;q=0.5" } - response = requests.get(yizhanchi_SearchUrl, params=yizhanchi_Search, headers=headers) + response = requests.get(yizhanchi_CitylistUrl, headers=headers) data = response.json() - # 提取职位信息 - items = data['data']['data'] + yizhanchi_city_id = None + for item in data["data"]: + if item["name"] == yizhanchi_city: + yizhanchi_city_id = item["id"] + break - # 按照refreshtime字段进行排序,降序排列 - sorted_items = sorted(items, key=lambda x: datetime.strptime(x['refreshtime'], "%Y-%m-%d %H:%M:%S"), reverse=True) - print("------------翼展翅APP-------------") - print("在翼展翅平台找到以下岗位,即将为您投递:") - print("---------------------------------") - # 仅显示 area_name 或 second_area_name 或 city_name 为 '深圳' 的结果 - for item in sorted_items: - city_name = item['city_name'] - area_name = item['area_name'] - second_area_name = item['second_area_name'] - if yizhanchi_city in [city_name, area_name, second_area_name]: - yizhanchi_findCount=yizhanchi_findCount + 1 - print(f"------------第{yizhanchi_findCount}家-------------") - positionid = item['positionid'] - companyname = item['companyname'] - positionname = item['positionname'] - salary_name = item['salary_name'] - refreshtime = item['refreshtime'] - position_strongpoint = item['position_strongpoint'] - print(f"UUID: {positionid}") - print(f"公司: {companyname}") - print(f"城市: {city_name}") - print(f"岗位: {positionname}") - print(f"薪资: {salary_name}") - print(f"福利: {position_strongpoint}") - print(f"HR刷新时间: {refreshtime}") - print("-------------Result---------------") - if(yizhanchi_poststate==1): - yizhanchi_postparams = { - 'attachment_id': "", - 'qiniu_id': "", - 'is_top': "1", - 'deliery_source': "4", - 'specific_source': "", - 'source': "" - } - yizhanchi_Postresponse = requests.get(yizhanchi_PostUrl+positionid, params=yizhanchi_postparams, headers=headers) - data = yizhanchi_Postresponse.json() - yizhanchi_yizhanchi_poststate = data['message'] - if yizhanchi_yizhanchi_poststate == '投递成功': - yizhanchi_successCount += 1 - delivery_info = { - "UUID": positionid, - "公司": companyname, - "城市": city_name, - "岗位": positionname, - "薪资": salary_name, - "福利": position_strongpoint, - # "投递来自": "在线简历" if usegroup == group_list[0] else "本地简历" + if yizhanchi_city_id is not None: + print(f'{yizhanchi_city}的id值是: {yizhanchi_city_id}') + else: + print(f'没有找到 name 为 "{yizhanchi_city}" 的数据') + return yizhanchi_findCount, yizhanchi_successCount, yizhanchi_errorCount + + yizhanchi_Search['region_id'] = f"{yizhanchi_city_id}" + + while True: + yizhanchi_Search['page'] = str(page) # 设置当前页码 + response = requests.get(yizhanchi_SearchUrl, params=yizhanchi_Search, headers=headers) + data = response.json() + items = data['data']['data'] + + if not items: + break + + sorted_items = sorted(items, key=lambda x: datetime.strptime(x['refreshtime'], "%Y-%m-%d %H:%M:%S"), reverse=True) + print("------------易展翅-------------") + print("在易展翅平台找到以下岗位,即将为您投递:") + print("---------------------------------") + + for item in sorted_items: + city_name = item['city_name'] + area_name = item['area_name'] + second_area_name = item['second_area_name'] + + if '深圳' in [city_name, area_name, second_area_name]: + yizhanchi_findCount += 1 + print(f"------------第{yizhanchi_findCount}家-------------") + positionid = item['positionid'] + companyname = item['companyname'] + positionname = item['positionname'] + salary_name = item['salary_name'] + refreshtime = item['refreshtime'] + position_strongpoint = item['position_strongpoint'] + print(f"UUID: {positionid}") + print(f"公司: {companyname}") + print(f"城市: {city_name}") + print(f"岗位: {positionname}") + print(f"薪资: {salary_name}") + print(f"福利: {position_strongpoint}") + print(f"HR刷新时间: {refreshtime}") + print("-------------Result---------------") + + if yizhanchi_poststate == 1: + yizhanchi_postparams = { + 'attachment_id': "", + 'qiniu_id': "", + 'is_top': "1", + 'deliery_source': "4", + 'specific_source': "", + 'source': "" } - successful_deliveries.append(delivery_info) + yizhanchi_Postresponse = requests.get(yizhanchi_PostUrl + positionid, params=yizhanchi_postparams, headers=headers) + data = yizhanchi_Postresponse.json() + yizhanchi_yizhanchi_poststate = data['message'] + if yizhanchi_yizhanchi_poststate == '投递成功': + yizhanchi_successCount += 1 + delivery_info = { + "UUID": positionid, + "公司": companyname, + "城市": city_name, + "岗位": positionname, + "薪资": salary_name, + "福利": position_strongpoint, + } + successful_deliveries.append(delivery_info) + else: + yizhanchi_errorCount += 1 + print("投递失败,请查看返回信息:") + print(yizhanchi_yizhanchi_poststate) else: - yizhanchi_errorCount += 1 - print("投递失败,请查看返回信息:") - print(yizhanchi_yizhanchi_poststate) - else: - print("您未开启翼展翅投递,本次投递跳过") - return yizhanchi_findCount, yizhanchi_successCount, yizhanchi_errorCount \ No newline at end of file + print("您未开启易展翅投递,本次投递跳过") + + page += 1 # 页码自增 + + return yizhanchi_findCount, yizhanchi_successCount, yizhanchi_errorCount