import time

import requests
from loguru import logger

from app.utils.common import get_proxies
from app.utils.ua import random_ua

headers = {
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7,zh-TW;q=0.6',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Origin': 'https://jubao.baidu.com',
    'Pragma': 'no-cache',
    'Referer': "",
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': random_ua(),
    'X-Requested-With': 'XMLHttpRequest',
    'sec-ch-ua_wap': '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
    'sec-ch-ua_wap-mobile': '?0',
    'sec-ch-ua_wap-platform': '"Windows"',
    "Cookie": "BIDUPSID=6E6F5ACEDDAE59C1C7F8BEDB76EE3472; PSTM=1743162000; BAIDUID=6E6F5ACEDDAE59C1C7F8BEDB76EE3472:FG=1; H_PS_PSSID=61027_61684_62227_62341_62371_62484_62327_62675_62687_62701_62618_62328_62693_62793_62759; Hm_lvt_90056b3f84f90da57dc0f40150f005d5=1743221214; HOSUPPORT=1; HOSUPPORT_BFESS=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BAIDUID_BFESS=6E6F5ACEDDAE59C1C7F8BEDB76EE3472:FG=1; BA_HECTOR=800l2k8g8404ak202180012h28e09b1juhubo23; ZFY=u7PzH9OEifErag4uR150Iqd3poJ4TvSXCPoa34vrghQ:C; pplogid=9018L%2BUrQhkdYh9xu5DGISHMKzFCdTvnDRpFspVuDw2cVdu0kPiicN3F%2BLIjIrS24Mnh97bf1rZ4jrYc4bfJjvviHKq3%2BcdD3k3cbzIyP7zjs%2FNbkRUI6ZXN2N6vpsW0vqz4; pplogid_BFESS=9018L%2BUrQhkdYh9xu5DGISHMKzFCdTvnDRpFspVuDw2cVdu0kPiicN3F%2BLIjIrS24Mnh97bf1rZ4jrYc4bfJjvviHKq3%2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vv4r6Ox6qCSA2GVhbcby9TZ0ZP/w8N2tU35oxlseq1LWgPu6XttGgSDD3qzeT+ioGRlVhowqdfR1aHkTtWeGpFIinbqcXU/T4f2hLII9D3g8/VJFpqtKhXSD3+Zxe9dMoovaJ+8O2a8FoOA61ANQdaSJ1gag0ZQYe+hQYRV64Y295VRIIti02vwfwuR8+zl4gzEd/6cK75U6uYcAhJpQbMAmzkzkW7nI8GFajWDjxAW3XV3NICTNZdymb5mwlfccpsD2YQGte0wan2iODRDe4PUg==; logTraceID=5654693b3d03476811e652cf58d1a0dfa472ce17028f7bafa0; UBI=fi_PncwhpxZ%7ETaKAchm6wmV2coOGs4YUtjch-4Zrot8sT1YSnNg1ybFt26pXcYEE5C284P8mos7AXpgAG4rABOEzOzPPcZDAjHxquBSVWmDg5el826AcbI7hmwaUmIF9sV05RVKkkUun2i%7En4ggkoXeqU8lxA__; UBI_BFESS=fi_PncwhpxZ%7ETaKAchm6wmV2coOGs4YUtjch-4Zrot8sT1YSnNg1ybFt26pXcYEE5C284P8mos7AXpgAG4rABOEzOzPPcZDAjHxquBSVWmDg5el826AcbI7hmwaUmIF9sV05RVKkkUun2i%7En4ggkoXeqU8lxA__; STOKEN=c6050c756de921fcb16f7dffc43dd50f2086995f8a899a6e00e920d811f567d2; BDUSS=V0VURQRFBRWGMyY05TdXB5cnpKaTZUUnNVUGllfk92MmQtc0FzSVU0eEQxUkJvSUFBQUFBJCQAAAAAAQAAAAEAAAASuE-WeGh5MjAyNQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENI6WdDSOlnZ2; PTOKEN=071414a8697fb7580d09c409b29c063c; BDUSS_BFESS=V0VURQRFBRWGMyY05TdXB5cnpKaTZUUnNVUGllfk92MmQtc0FzSVU0eEQxUkJvSUFBQUFBJCQAAAAAAQAAAAEAAAASuE-WeGh5MjAyNQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENI6WdDSOlnZ2; STOKEN_BFESS=c6050c756de921fcb16f7dffc43dd50f2086995f8a899a6e00e920d811f567d2; PTOKEN_BFESS=071414a8697fb7580d09c409b29c063c; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; delPer=0; PSINO=5",
}

surl = "https://www.yunzhiju.net/jxfsxf/"
token = "0DE59186A7A5F2F6F8D41B95ED9E26D0"
title = "深入解析游戏玩法-轻松上手,提升游戏技巧-云之居软件园"
q = "www.yunzhiju.net/jxfsxf/"
timestamp_s = int(time.time() * 1000)
url = "https://passport.baidu.com/cap/init"
data = {
    "_": int(time.time() * 1000),
    "refer": f"http://jubao.baidu.com/jubao/accu/?surl={surl}&token={token}&title={title}&q={q}&has_gw=0&has_v=0&_t8={timestamp_s}",
    "ak": "76AKmP4xDQjB3vAIPef3KxOlJZWCpw64",
    "ver": "2",
    "scene": "",
    "ds": "",
    "tk": "",
    "as": "",
    "reinit": 0
}
logger.debug(f"{headers=}")
logger.debug(f"{data=}")
response = requests.post(url, headers=headers, data=data, proxies={
    "http": "http://localhost:8080/",
    "https": "http://localhost:8080/"
}, verify=False).json()
logger.success(response)
