-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaptcha.py
More file actions
54 lines (46 loc) · 1.65 KB
/
captcha.py
File metadata and controls
54 lines (46 loc) · 1.65 KB
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
46
47
48
49
50
51
52
53
import requests
from twocaptcha import TwoCaptcha
FAUCET_URL = 'https://faucet.triangleplatform.com/api/request'
SITEKEY_V2 = '6LfuM6giAAAAAOSzQAA57VwKBSEOgcRstYXUGqTa'
FAUCET_PAGE_URL = 'https://faucet.triangleplatform.com/abstract/testnet'
CAPTCHA_API_KEY = 'bd4d3ef0cd278588efb7e552c0a16336'
solver = TwoCaptcha(CAPTCHA_API_KEY)
def send_faucet_request(wallet_address, proxy, max_retries):
captcha_proxy = proxy['https'][8:]
try:
print("Solving captcha...")
token_v2 = solver.recaptcha(
sitekey=SITEKEY_V2,
url=FAUCET_PAGE_URL,
proxy={'type': 'HTTPS', 'uri': captcha_proxy}
)
print("Captcha solved!")
payload = {
"address": wallet_address,
"network": "abstract_testnet",
"token_v2": token_v2['code']
}
retry = 0
while retry < max_retries:
try:
response = requests.post(
url=FAUCET_URL,
json=payload,
proxies=proxy,
timeout=10,
verify=False
)
if 'explorer_url' in response.text:
print('Successfully funded 0.001 ETH!')
return True
else:
print("Failed to fund. Response:", response.text)
return False
except requests.exceptions.RequestException:
print("Proxy failed")
print('retrying...')
retry += 1
print('Max retries reached. Exiting.')
return False
except Exception as err:
print('Captcha error', err)