Crawler/web/yutian_top/Download_.py

117 lines
3.6 KiB
Python

import logging
from Requests_Except import MR
from web.yutian_top.main import default_cookies, Requests
base_url = 'www.yutian.top'
protocol = 'https'
default_headers = {
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
'content-type': 'application/json;charset=UTF-8',
'origin': 'https://www.yutian.top',
'pragma': 'no-cache',
'priority': 'u=1, i',
'referer': 'https://www.yutian.top/enterprise/resume_store/list',
'sec-ch-ua': '"Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
}
default_cookies = {
'PHPSESSID': 'cac0b0c651b27ad30642869a4304c098',
'auth-token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDU4NDg3MTUsImp0aSI6IjcwNjc4MWQ3LTJjMWYtNGZiZS04ZDM4LWRhMDRmYjdiMjljOSIsIm5hbWUiOiIxODYxNzg3MjE4NSIsInVzZXJfaWQiOiIwM2M2MmI5ODM4Yjk3Y2UzYmQxZTQwNDllZGVlNmI0OCIsInRlbmFudF90b2tlbiI6IjY1OTAxM2RlNjAxZmJmNjg1MzZmYTU0OTc4ODVkMTA2In0.1FH4SBYQu0CYhEzCzMlYBYZ2YsSM9kgkXWmgXcZ88Bs',
'company_sign': '',
'company_nonce': '',
'cuid': '',
}
Requests = MR(base_url, protocol)
Requests.set_default_headers(default_headers)
Requests.set_default_cookies(default_cookies)
psdata = {
"resume_id": [],
"姓名": [], # user_name
"电话": [], # phone_encrypt
}
Down = [20891, 19784, 19715, 19280, 18130, 17890, 1770, 17078, 15460, 15424, 14868, 13687, 13517, 11724, 9513, 9454,
8161, 3372, 3065, 993, 988]
def buyResumeUserPhone(resume_id):
json_data = {
'resume_id': resume_id,
'from_type': '',
}
res = Requests.post('/job/company/v1/company/buyResumeUserPhone', json=json_data)
return res.to_Dict()
def getResumeDownloadLink(resume_id):
json_data = {
'resume_id': resume_id,
'delivery_id': '',
}
res = Requests.post('/job/company/v1/company/getResumeDownloadLink', json=json_data)
return res.to_Dict()
def getResumeUserPhone(resume_id):
json_data = {
'resume_id': resume_id,
'delivery_id': '',
'is_pc': 1,
}
url = '/job/company/v1/company/getResumeUserPhone'
resp = Requests.post(url, json=json_data)
return resp.to_Dict()
def get_resume_info(resume_id):
json_data = {
'resume_id': resume_id,
}
url = '/job/company/v1/resume/loadResume'
resp = Requests.post(url, json=json_data)
return resp.to_Dict()
def integrate():
for r_id in Down:
user_info = get_resume_info(r_id)
u_name = user_info.user_name
r_info = getResumeUserPhone(r_id)
try:
phone = r_info.phone
except Exception as e:
phone = None
# print(f"姓名: {u_name}, 电话: {phone}")
if phone is None :
res = buyResumeUserPhone(r_id)
print(res, r_id)
if res.buy_success:
print("购买成功!")
r_info = getResumeUserPhone(r_id)
phone = r_info.phone
psdata['resume_id'].append(r_id)
psdata['姓名'].append(u_name)
psdata['电话'].append(phone)
def write_to_excel():
import pandas as pd
df = pd.DataFrame(psdata)
df.to_excel('resume_data.xlsx', index=True)
print("数据已写入 resume_data.csv")
if __name__ == '__main__':
integrate()
write_to_excel()