From 4b99b930ed1844ecff10512ef4f5ec8790bd0f04 Mon Sep 17 00:00:00 2001 From: mole828 Date: Mon, 8 Jul 2024 00:25:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E6=88=90=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=EF=BC=8C=E5=87=86=E5=A4=87=E6=B5=8B=E8=AF=95?= =?UTF-8?q?ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/checkin.yml | 5 +++-- api.py | 39 +++++++++++++++++++++++++---------- recaptcha.py | 2 ++ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/checkin.yml b/.github/workflows/checkin.yml index 278b534..a403300 100644 --- a/.github/workflows/checkin.yml +++ b/.github/workflows/checkin.yml @@ -1,8 +1,8 @@ name: checkin on: - # schedule: - # - cron: '21 0 * * *' + schedule: + - cron: '21 0 * * *' workflow_dispatch: jobs: @@ -20,5 +20,6 @@ jobs: - name: Run Checkin env: SESSIONS: ${{ secrets.SESSIONS }} + EZCAPTCHA_CLIENT_KEY: ${{ secrets.SESSIONS }} run: | python main.py diff --git a/api.py b/api.py index c23c200..c49aa54 100644 --- a/api.py +++ b/api.py @@ -2,6 +2,14 @@ import requests from recaptcha import CaptchaInterface +def _recap(captcha_interface: CaptchaInterface): + return captcha_interface.cap( + websiteURL='https://2dfan.com/', + websiteKey='6LdUG0AgAAAAAAfSmLDXGMM7XKYMTItv87seZUan', + pageAction="checkin", + isInvisible=True, + ) + class User: session: requests.Session captcha_interface: CaptchaInterface @@ -9,27 +17,25 @@ class User: def __init__(self, session: str, captcha_interface: CaptchaInterface) -> None: self.session = requests.Session() self.session.headers.update({ - 'accept': 'application/json, text/javascript, */*; q=0.01', + 'accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'accept-language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8', + 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', + # 'cookie': '_ga=GA1.1.1106942088.1711578378; pop-blocked=true; _ga_RF77TZ6QMN=GS1.1.1720365165.27.1.1720366078.0.0.0; _project_hgc_session=4z0HMXrKqKm0FPT9eKC%2BEy3vAGst%2F%2BlwdigcuvHWectxz4tGlZkaMPLXM5RSL%2FqImdQkYCC0xKljeVFYd3HWldmh37WiX5xqcpw4pQYXSU4SnaKKFt9LCC5boe0AehNEQgXgASKtIFL0sj%2FOBu8A3rpMIvfFdXxjY%2FuxwRFGeS75gVo3tCcFSnOW6NKduYZ6uwFhyM872dqPRpgo6TTpakEu4VlW4kqV5bE21KfqMFZoQAvXe3qsk6QpIeS7TqqMDTOM%2Bd3llcaoLXPetfsSDgSOLiFwlfWjKpCCvh9g%2BCtpyVp34I388ZaIZsmQLU9%2BLu%2B9kf2Kh5drHP8KDbNBlRk%2BkCceTWs1fyssuPzTNjWoKzVP1IjZkLfZUe8%2F8rGgaCaNIjCczZBZbeQrg8j0CiuUlYuyfnv8JQjmMrrJTof19NjYEMiNTg%3D%3D--Xhv6nFAyw1bh9yeH--8cCB5xrV%2B%2FrGaps3sqYAvw%3D%3D', 'origin': 'https://2dfan.com', - 'sec-ch-ua': '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"', + 'priority': 'u=1, i', + 'referer': 'https://2dfan.com/', + 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"macOS"', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36', - 'x-csrf-token': 'cg30SzeY1l6AR/hJeSu2OEVfftVyNKuJfaNnK5cPqe0i1IFXJxO0Dpro10YE3vU27YkETUylcpZfs7CgBbOUbQ==', + 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + 'x-csrf-token': 'a6txQY0VLaHp-MNxTSRlVS_G4FhmfeWft_PaAPelgexVdutFj85POF4Q3oNypAh13hLGLFSYjwnhNQuPp_qC3A', 'x-requested-with': 'XMLHttpRequest', }) self.session.cookies.update({ '_project_hgc_session': session, - 'g-recaptcha-response-data': captcha_interface.cap( - websiteURL='https://2dfan.com/', - websiteKey='6LdUG0AgAAAAAAfSmLDXGMM7XKYMTItv87seZUan', - pageAction="checkin", - isInvisible=True, - ), }) self.captcha_interface = captcha_interface @@ -45,7 +51,18 @@ def from_json(json_str: str): def checkin(self) -> CheckinResult: - response = self.session.post(url= 'https://2dfan.com/checkins') + response = self.session.post(url= 'https://2dfan.com/checkins', data={ + 'g-recaptcha-response-data[checkin]': self.captcha_interface.cap( + websiteURL='https://2dfan.com/', + websiteKey='6LdUG0AgAAAAAAfSmLDXGMM7XKYMTItv87seZUan', + pageAction="checkin", + isInvisible=True, + ), + 'authenticity_token': self.session.cookies.get('x-csrf-token'), + 'format': 'json', + 'g-recaptcha-response': '', + 'button': '', + }) return User.CheckinResult.from_json(response.text) diff --git a/recaptcha.py b/recaptcha.py index 0907f15..5f5370a 100644 --- a/recaptcha.py +++ b/recaptcha.py @@ -85,7 +85,9 @@ def cap( isInvisible: bool = False, ) -> str: task_id = self.__create_task(websiteURL,websiteKey,pageAction,type,isInvisible) + print('wait cap', end='') result = self.__get_task_result(task_id) + print('done') return result