forked from ymmmmmmmm/BeraChainTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.py
45 lines (37 loc) · 1.46 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
# Time :2024/1/19 21:38
# Author :ym
# File :utils.py
import os
import time
from typing import Union
import requests
from dotenv import load_dotenv
load_dotenv()
proxy_url = os.getenv("PROXY_URL")
YesCaptchaClientKey = os.getenv("YesCaptchaClientKey")
def get_ip():
if proxy_url == 'null':
return False
response = requests.get(url=proxy_url).text.strip().replace('\n', '')
return {"http": f'http://{response}', "https": f'http://{response}'}
def get_google_token() -> Union[bool, str]:
json_data = {"clientKey": YesCaptchaClientKey,
"task": {"websiteURL": "https://artio.faucet.berachain.com/",
"websiteKey": "6LfOA04pAAAAAL9ttkwIz40hC63_7IsaU2MgcwVH",
"type": "RecaptchaV3TaskProxylessM1S7", "pageAction": "submit"}, "softID": 109}
response = requests.post(url='https://api.yescaptcha.com/createTask', json=json_data).json()
if response['errorId'] != 0:
raise ValueError(response)
task_id = response['taskId']
time.sleep(5)
for _ in range(30):
data = {"clientKey": YesCaptchaClientKey, "taskId": task_id, }
response = requests.post(url='https://api.yescaptcha.com/getTaskResult', json=data).json()
if response['status'] == 'ready':
return response['solution']['gRecaptchaResponse']
else:
time.sleep(2)
return False
if __name__ == '__main__':
print(get_google_token())