Skip to content

Commit

Permalink
fix: 完成本地运行,准备测试ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mole828 committed Jul 7, 2024
1 parent 7e09b43 commit 4b99b93
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: checkin

on:
# schedule:
# - cron: '21 0 * * *'
schedule:
- cron: '21 0 * * *'
workflow_dispatch:

jobs:
Expand All @@ -20,5 +20,6 @@ jobs:
- name: Run Checkin
env:
SESSIONS: ${{ secrets.SESSIONS }}
EZCAPTCHA_CLIENT_KEY: ${{ secrets.SESSIONS }}
run: |
python main.py
39 changes: 28 additions & 11 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@
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

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

Expand All @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions recaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 4b99b93

Please sign in to comment.