import requests
import scrapy
import json

from pyasn1_modules.rfc7292 import pbeWithSHAAnd40BitRC4
from requests import session

# 尽量不要跑这个脚本太他妈慢了

class FnrcVipSpider(scrapy.Spider):
    name = 'fnrc_vip'

    def start_requests(self):
        url = "https://www.fnrc.vip/job/company/v1/resume/page"
        cookies = {
            'PHPSESSID': 'ca613ae99706037e356a247500acb97b',
            'auth-token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDczNzA1ODUsImp0aSI6IjBlZDI0NTM0LWE0NjEtNDkxNC1iNDU1LWQxZGEzYzQ5N2U0NiIsIm5hbWUiOiIxODYxNzg3MjE4NSIsInVzZXJfaWQiOiIxYTJkODFjMTFkM2MzMmVhYmVlNWFkM2E3NGFmYWViNyIsInRlbmFudF90b2tlbiI6ImQzNWVjMmEzNjAxODM1NWE4MTg3ZTEyODI3MzE3ZGRjIn0.HoaWksDiMxtkbBJ8jVPlKLKzd1UqNHo4KfecS2uVUaM',
            'company_sign': '',
            'company_nonce': '',
            'cuid': '',
        }

        headers = {
            'accept': 'application/json, text/plain, */*',
            'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'cache-control': 'no-cache',
            'content-type': 'application/json;charset=UTF-8',
            'origin': 'https://www.fnrc.vip',
            'pragma': 'no-cache',
            'priority': 'u=1, i',
            'referer': 'https://www.fnrc.vip/enterprise/resume_store/list',
            'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
            '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/135.0.0.0 Safari/537.36',
        }

        json_data = {
            'step': 1000,
            'page': 1,
            'education_level': [],
            'arrival_time': [],
            'work_time': [],
            'area_id': [],
            'keywords': '',
            'work_status': '',
            'work_status_show': '求职状态',
            'category_id': '',
            'work_type': '',
            'work_type_show': '是否兼职',
            'sex': '',
            'sex_show': '性别',
            'is_head': '',
            'is_head_show': '有无照片',
            'job_id': '',
            'age': [],
            'age_show': '年龄',
            'refresh_time': 0,
            'site_id': '',
            'site_id2': '',
            'province': '',
            'city': '',
            'county': '',
            'provinceArr': [],
            'cityArr': [],
            'countyArr': [],
            'only_job_category': 0,
        }
        session = requests.Session()
        session.headers.update(headers)
        session.cookies.update(cookies)
        for page in range(1, 6):
            payload = {
                'step': 1000,
                'page': page,
                'education_level': [],
                'arrival_time': [],
                'work_time': [],
                'area_id': [],
                'keywords': '',
                'work_status': '',
                'work_status_show': '求职状态',
                'category_id': '',
                'work_type': '',
                'work_type_show': '是否兼职',
                'sex': '',
                'sex_show': '性别',
                'is_head': '',
                'is_head_show': '有无照片',
                'job_id': '',
                'age': [],
                'age_show': '年龄',
                'refresh_time': 0,
                'site_id': '',
                'site_id2': '',
                'province': '',
                'city': '',
                'county': '',
                'provinceArr': [],
                'cityArr': [],
                'countyArr': [],
                'only_job_category': 0,
            }

            response = session.post(url, json=payload)
            data = response.json()

            for item in data.get('data', []):
                yield item