This commit is contained in:
Administrator
2025-11-12 12:54:37 +08:00
commit a0720d80dc
3954 changed files with 1158090 additions and 0 deletions

320
bitgit/main.py Normal file
View File

@@ -0,0 +1,320 @@
import random
import re
import string
import time
from concurrent.futures import ThreadPoolExecutor
import pyotp
from DrissionPage._configs.chromium_options import ChromiumOptions
from DrissionPage._pages.chromium_page import ChromiumPage
from loguru import logger
from hub_web.hub_tools import get_page
from models.bitgit import Bitgit
from models.ips import Ips
from tools123123.email123 import get_verify_code
from 比特.bit_tools import openBrowser
def extract_numbers(text):
# 正则表达式模式,用于匹配整数、浮点数和科学计数法表示的数字
pattern = r'[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?'
# 使用 findall 方法查找所有匹配的数值
numbers = re.findall(pattern, text)
# 将匹配到的字符串转换为相应的数值类型
numbers = [float(num) if '.' in num or 'e' in num.lower() else int(num) for num in numbers]
return numbers[0]
class BitGit():
def __init__(self, bitgit_inf):
self.bitgit_info = bitgit_inf
self.ips_info = Ips.get_or_none(Ips.id == self.bitgit_info.ip_id)
self.page = None
def totp_now(self):
code = pyotp.totp.TOTP(self.bitgit_info.two_fa).now()
return code
def get_user_data(self, bitgit_info):
self.bitgit_tab.get("https://www.bitget.com/zh-CN/asset/recharge")
time.sleep(5)
self.bitgit_tab.ele('x://span[text()="SOL"]').click()
time.sleep(3)
self.bitgit_tab.ele('x://*[@id="rc_select_2"]').click()
time.sleep(3)
self.bitgit_tab.ele('x://div[text()="Solana"]').click()
time.sleep(5)
self.bitgit_tab.refresh(ignore_cache=True)
time.sleep(5)
address = self.bitgit_tab.ele(
'x://*[@id="root"]/div/div[2]/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/div/span[2]/div/span/div/div').text
self.bitgit_tab.ele(
'x://*[@id="MicroHeaderFrame"]/div[2]/div[3]/div[8]').click()
time.sleep(3)
uuid = self.bitgit_tab.ele(
'x://div[@class="not-jump mt-2px flex items-center text-thirdText text-12px cursor-pointer leading-18px"]').text
user_name = self.bitgit_tab.ele(
'x://*[@id="MicroHeaderFrame"]/div[2]/div[3]/div[8]/div[2]/div/div/div[1]/div[1]/div/div[2]/div[2]/div[1]').text
print(uuid, user_name)
bitgit_info.user_name = user_name
bitgit_info.uuid = extract_numbers(uuid)
bitgit_info.address = address
bitgit_info.save()
def get_page(self, ):
try:
bit_port = openBrowser(id=self.bitgit_info.bit_id)
co = ChromiumOptions()
co.set_local_port(port=bit_port)
self.page = ChromiumPage(addr_or_opts=co)
self.page.set.window.max()
return True
except:
pass
return False
def action(self):
try:
if self.get_page():
logger.info(f"浏览器打开成功")
else:
logger.error(f"浏览器打开失败")
return
for _, i in enumerate(self.page.get_tabs()):
if _ == 0:
continue
i.close()
self.bitgit_tab = self.page.new_tab("https://www.bitget.com/zh-CN/")
try:
a = self.bitgit_tab.ele('x://span[text()="I am not a UK user"]', timeout=10)
if a:
a.click()
self.bitgit_tab.ele('x://a[text()="登录"]').click()
time.sleep(10)
input_ele = self.bitgit_tab.ele('x://input[@placeholder="手机/邮箱"]', timeout=10)
if input_ele:
input_ele.input(vals=self.bitgit_info.email, clear=True)
self.bitgit_tab.ele('x://span[normalize-space(text())="验证"]').click()
input_ele = self.bitgit_tab.ele('x://input[@placeholder="密码"]', timeout=9999)
if input_ele:
input_ele.input("Hxsd123456@..")
self.bitgit_tab.ele('x://span[normalize-space(text())="立即登录"]').click()
button_ele = self.bitgit_tab.ele('x://span[normalize-space(text())="继续"]', timeout=10)
if button_ele:
button_ele.click()
time.sleep(5)
# 输入邮箱的验证码
try:
if self.bitgit_tab.ele(f'x://input[@data-testid="2FAEmailCodeInput0"]', timeout=10):
code = get_verify_code(self.bitgit_info.email, 0)[0]
for _, i in enumerate(code):
self.bitgit_tab.ele(f'x://input[@data-testid="2FAEmailCodeInput{_}"]').input(i)
time.sleep(1)
except:
pass
# 输入谷歌验证器的验证码
try:
if self.bitgit_tab.ele(f'x://input[@data-testid="2FAGoogleCodeInput0"]', timeout=10):
for _, i in enumerate(self.totp_now()):
self.bitgit_tab.ele(f'x://input[@data-testid="2FAGoogleCodeInput{_}"]').input(i)
time.sleep(1)
except:
pass
except:
pass
# 获取key----------------------------------------------------------------------------------------------------
self.bitgit_tab.get(url="https://www.bitget.com/zh-CN/account/newapi")
span_ele = self.bitgit_tab.ele('x://span[normalize-space(text())="同意"]', timeout=10)
if span_ele:
span_ele.click()
time.sleep(5)
self.bitgit_tab.ele('x://button[@data-testid="NewApiCreateApiButton"]').click()
time.sleep(1)
self.bitgit_tab.ele('x://h3[text()="系统生成的 API 密钥"]').click()
time.sleep(1)
# 获取所有小写字母
letters = string.ascii_lowercase
self.bitgit_tab.ele('x://input[@data-testid="NewApiCreateDialogRemarkInput"]').input(
''.join(random.choice(letters) for i in range(8))) # 输入备注名
time.sleep(1)
self.bitgit_tab.ele('x://input[@data-testid="NewApiCreateDialogApiCodeInput"]').input("hx123456") # 输入备注名
time.sleep(1)
self.bitgit_tab.ele('x://span[normalize-space(text())="只读权限"]', timeout=10).click()
time.sleep(1)
self.bitgit_tab.ele('x://span[@class="bit-checkbox__inner"]').click()
time.sleep(1)
self.bitgit_tab.ele('x://textarea[@placeholder="单个地址直接填写,多个 IP 地址用半角逗号分离"]').input(
self.ips_info.ip) # 输入备注名
time.sleep(1)
self.bitgit_tab.ele('x://span[normalize-space(text())="下一步"]', timeout=10).click()
time.sleep(5)
self.bitgit_tab.ele('x://button[@data-testid="2FAEmailCodeSendButton"]').click()
time.sleep(10)
# 输入邮箱的验证码
try:
if self.bitgit_tab.ele(f'x://input[@data-testid="2FAEmailCodeInput0"]', timeout=10):
code = get_verify_code(self.bitgit_info.email, 0)[0]
for _, i in enumerate(code):
self.bitgit_tab.ele(f'x://input[@data-testid="2FAEmailCodeInput{_}"]').input(i)
time.sleep(1)
except:
pass
# 输入谷歌验证器的验证码
try:
if self.bitgit_tab.ele(f'x://input[@data-testid="2FAGoogleCodeInput0"]', timeout=10):
for _, i in enumerate(self.totp_now()):
self.bitgit_tab.ele(f'x://input[@data-testid="2FAGoogleCodeInput{_}"]').input(i)
time.sleep(1)
except:
pass
self.bitgit_tab.ele('x://span[text()="确定"]').click()
time.sleep(50)
# apikey = self.bitgit_tab.ele(
# 'x://*[@id="__layout"]/div/div[3]/div/div[2]/div/div/div[7]/div/div[2]/div/div/div[1]/div[1]/div/div').text
# SecretKey = self.bitgit_tab.ele(
# 'x://*[@id="__layout"]/div/div[3]/div/div[2]/div/div/div[7]/div/div[2]/div/div/div[1]/div[2]/div/div').text
#
# print(apikey)
# print(SecretKey)
#
# self.bitgit_info.apikey = apikey
# self.bitgit_info.SecretKey = SecretKey
#
# self.bitgit_info.save()
#
# self.bitgit_tab.ele('x://span[normalize-space(text())="确定"]', timeout=10).click()
# # --------------------------------------------------------------------------------------------------------------
# self.bitgit_tab.get("https://www.bitget.com/zh-CN/asset/recharge?coinId=122&chainCoinId=3000")
# time.sleep(15)
#
# ele = self.bitgit_tab.ele('x://*[@id="react-joyride-step-0"]/div/div/div/div/div[2]/div[2]/span[1]',
# timeout=10)
# if ele:
# ele.click()
#
# # 切到主号
# self.bitgit_tab.ele(
# 'x://*[@id="MicroHeaderFrame"]/div[2]/div[3]/div[8]').click()
# time.sleep(5)
# self.bitgit_tab.ele('x://div[@class="flex gap-10px self-end"]').click()
# time.sleep(5)
# self.bitgit_tab.ele('x://*[@id="pane-first"]/div[2]/div[1]').click()
# time.sleep(5)
#
# # 获取主号的数据
# self.bitgit_tab.get("https://www.bitget.com/zh-CN/asset/recharge?coinId=122&chainCoinId=3000")
#
# bitgit_info, type1 = BitgitAddress.get_or_create(
# email=self.bitgit_info.email,
# user_name1=None,
# )
#
# self.get_user_data(bitgit_info)
#
# # 点击切换转户
# time.sleep(3)
# self.bitgit_tab.ele('x://div[@class="flex gap-10px self-end"]').click()
# time.sleep(3)
#
# # 滚动
# for i in range(3):
# self.bitgit_tab.actions.move_to('x://li[@class="list-item account-line"][last()]').scroll(
# delta_y=99)
# time.sleep(1)
#
# mini_user = self.bitgit_tab.eles('x://ul[@class="list"]/li')
#
# for i in range(20):
# bitgit_info, type1 = BitgitAddress.get_or_create(
# email=self.bitgit_info.email,
# user_name1=mini_user[i].ele('x:./div[2]/div[1]').text
# )
#
# if bitgit_info.address:
# continue
#
# mini_user[i].click()
#
# time.sleep(5)
# self.get_user_data(bitgit_info=bitgit_info)
#
# self.bitgit_tab.ele('x://div[@class="flex gap-10px self-end"]').click()
# time.sleep(5)
#
# # 滚动
# for i in range(3):
# self.bitgit_tab.actions.move_to('x://li[@class="list-item account-line"][last()]').scroll(
# delta_y=99)
# time.sleep(1)
#
# mini_user = self.bitgit_tab.eles('x://ul[@class="list"]/li')
#
# time.sleep(5)
time.sleep(10)
except Exception as e:
print(e)
finally:
self.page.quit()
if __name__ == '__main__':
max_threads = 1
delay_between_start = 10 # 每次启动线程之间的延迟时间(秒)
with ThreadPoolExecutor(max_workers=max_threads) as executor:
for bitgit_inf in Bitgit.select().where(Bitgit.start.is_null()):
bitgit_web = BitGit(bitgit_inf)
# bitgit_web.action()
executor.submit(bitgit_web.action)
time.sleep(delay_between_start)

13
bitgit/匹配ip.py Normal file
View File

@@ -0,0 +1,13 @@
from models.bitgit import Bitgit
from models.ips import Ips
def get_ip_id():
for ip in Ips.select().where(Ips.ip_start.is_null()):
if len(Bitgit.select().where(Bitgit.ip_id == ip.id)) < 2:
return ip.id
for i in Bitgit.select():
i.ip_id = get_ip_id()
i.save()

View File

@@ -0,0 +1,138 @@
import base64
import hashlib
import hmac
import time
import requests
class BitgetAPI:
def __init__(self, api_key, secret_key, passphrase, proxies=None):
self.api_key = api_key
self.secret_key = secret_key
self.passphrase = passphrase
self.base_url = 'https://api.bitget.com'
self.session = requests.Session()
if proxies:
self.session.proxies.update(proxies)
self.session.headers.update({
'ACCESS-KEY': self.api_key,
'ACCESS-PASSPHRASE': self.passphrase,
'Content-Type': 'application/json',
'locale': 'zh-CN'
})
def _sign(self, params, request_path):
timestamp = str(int(time.time() * 1000))
query_string = '&'.join([f"{key}={value}" for key, value in params.items()])
if params:
prehash_string = timestamp + 'GET' + request_path + '?' + query_string
else:
prehash_string = timestamp + 'GET' + request_path
signature = hmac.new(self.secret_key.encode('utf-8'), prehash_string.encode('utf-8'), hashlib.sha256).digest()
signature_base64 = base64.b64encode(signature).decode('utf-8')
return timestamp, signature_base64, query_string
def _send_request(self, method, request_path, params=None):
if not params:
params = {}
timestamp, signature_base64, query_string = self._sign(params, request_path)
self.session.headers["ACCESS-SIGN"] = signature_base64
self.session.headers["ACCESS-TIMESTAMP"] = timestamp
url = f"{self.base_url}{request_path}?{query_string}"
response = self.session.request(method, url)
try:
return response.json()
except ValueError:
print(f"请求失败,返回内容非 JSON 格式: {response.text}")
return None
def get_virtual_subaccount_list(self, limit=20):
request_path = '/api/v2/user/virtual-subaccount-list'
params = {
"limit": str(limit),
}
return self._send_request('GET', request_path, params)
def get_subaccount_deposit_address(self, coin, chain, sub_uid):
request_path = '/api/v2/spot/wallet/subaccount-deposit-address'
params = {
"coin": coin,
"chain": chain,
"subUid": sub_uid,
}
return self._send_request('GET', request_path, params)
def get_account_info(self):
request_path = '/api/v2/spot/account/info'
params = {}
return self._send_request('GET', request_path, params)
def get_subaccount_user_id(self):
request_path = '/api/v2/spot/account/info'
params = {}
response = self._send_request('GET', request_path, params)
if response and 'data' in response and 'userId' in response['data']:
return response['data']['userId']
return None
def get_subaccount_address(self, coin, chain):
request_path = '/api/v2/spot/wallet/deposit-address'
params = {
"coin": coin,
"chain": chain,
}
response = self._send_request('GET', request_path, params)
if response and 'data' in response and 'address' in response['data']:
return response['data']['address']
return None
def get_userid_and_address(self, coin, chain):
userid_and_address = {}
# 获取主账户的信息
main_user_id = self.get_subaccount_user_id()
if main_user_id:
main_address = self.get_subaccount_address(coin, chain)
if main_address:
userid_and_address[main_user_id] = main_address
# 获取虚拟子账户列表
subaccounts_response = self.get_virtual_subaccount_list()
if subaccounts_response and 'data' in subaccounts_response and 'subAccountList' in subaccounts_response['data']:
subaccounts = subaccounts_response['data']['subAccountList']
for subaccount in subaccounts:
sub_uid = subaccount['subAccountUid']
deposit_address_response = self.get_subaccount_deposit_address(coin, chain, sub_uid)
if deposit_address_response and 'data' in deposit_address_response and 'address' in \
deposit_address_response['data']:
userid_and_address[sub_uid] = deposit_address_response['data']['address']
return userid_and_address
if __name__ == '__main__':
# 替换为您的 API 密钥信息
api_key = 'bg_de5d1fee9b211c0da479e7061aa5d45a'
secret_key = 'b94d9d470338ca84045ab1f6222d15954e7422de9e3a83a020f1b31446571b93'
passphrase = '040828cjj'
proxies = {
'http': f'socks5h://L2924:B928192@31.57.104.140:30000',
'https': f'socks5h://L2924:B928192@31.57.104.140:30000'
}
params = {
"coin": "SOL",
"chain": "sol",
}
bitget_api = BitgetAPI(api_key, secret_key, passphrase, proxies)
userid_and_address = bitget_api.get_userid_and_address(params["coin"], params["chain"])
print(userid_and_address)

173
bitgit/接口/main.py Normal file
View File

@@ -0,0 +1,173 @@
import base64
import hashlib
import hmac
import time
import loguru
import requests
from models.bitgit import Bitgit
from models.bitgit_address import BitgitAddress
from models.ips import Ips
from tomorrow3 import threads
class BitgetAPI:
def __init__(self, api_key, secret_key, passphrase, proxies=None):
self.api_key = api_key
self.secret_key = secret_key
self.passphrase = passphrase
self.base_url = 'https://api.bitget.com'
self.session = requests.Session()
if proxies:
self.session.proxies.update(proxies)
self.session.headers.update({
'ACCESS-KEY': self.api_key,
'ACCESS-PASSPHRASE': self.passphrase,
'Content-Type': 'application/json',
'locale': 'zh-CN'
})
def _sign(self, params, request_path):
timestamp = str(int(time.time() * 1000))
query_string = '&'.join([f"{key}={value}" for key, value in params.items()])
if params:
prehash_string = timestamp + 'GET' + request_path + '?' + query_string
else:
prehash_string = timestamp + 'GET' + request_path
signature = hmac.new(self.secret_key.encode('utf-8'), prehash_string.encode('utf-8'), hashlib.sha256).digest()
signature_base64 = base64.b64encode(signature).decode('utf-8')
return timestamp, signature_base64, query_string
def _send_request(self, method, request_path, params=None):
if not params:
params = {}
timestamp, signature_base64, query_string = self._sign(params, request_path)
self.session.headers["ACCESS-SIGN"] = signature_base64
self.session.headers["ACCESS-TIMESTAMP"] = timestamp
url = f"{self.base_url}{request_path}?{query_string}"
response = self.session.request(method, url)
try:
return response.json()
except ValueError:
print(f"请求失败,返回内容非 JSON 格式: {response.text}")
return None
def get_virtual_subaccount_list(self, limit=20):
request_path = '/api/v2/user/virtual-subaccount-list'
params = {
"limit": str(limit),
}
return self._send_request('GET', request_path, params)
def get_subaccount_deposit_address(self, coin, chain, sub_uid):
request_path = '/api/v2/spot/wallet/subaccount-deposit-address'
params = {
"coin": coin,
"chain": chain,
"subUid": sub_uid,
}
return self._send_request('GET', request_path, params)
def get_account_info(self):
request_path = '/api/v2/spot/account/info'
params = {}
return self._send_request('GET', request_path, params)
def get_subaccount_user_id(self):
request_path = '/api/v2/spot/account/info'
params = {}
response = self._send_request('GET', request_path, params)
if response and 'data' in response and 'userId' in response['data']:
return response['data']['userId']
return None
def get_subaccount_address(self, coin, chain):
request_path = '/api/v2/spot/wallet/deposit-address'
params = {
"coin": coin,
"chain": chain,
}
response = self._send_request('GET', request_path, params)
if response and 'data' in response and 'address' in response['data']:
return response['data']['address']
return None
def get_userid_and_address(self, coin, chain):
userid_and_address = {}
# 获取主账户的信息
main_user_id = self.get_subaccount_user_id()
if main_user_id:
main_address = self.get_subaccount_address(coin, chain)
if main_address:
userid_and_address[main_user_id] = main_address
# 获取虚拟子账户列表
subaccounts_response = self.get_virtual_subaccount_list()
if subaccounts_response and 'data' in subaccounts_response and 'subAccountList' in subaccounts_response['data']:
subaccounts = subaccounts_response['data']['subAccountList']
for subaccount in subaccounts:
sub_uid = subaccount['subAccountUid']
deposit_address_response = self.get_subaccount_deposit_address(coin, chain, sub_uid)
if deposit_address_response and 'data' in deposit_address_response and 'address' in \
deposit_address_response['data']:
userid_and_address[sub_uid] = deposit_address_response['data']['address']
return userid_and_address
@threads(50) # 指定线程数为4
def main(bitgit_info1):
try:
loguru.logger.info(f"{bitgit_info1},开始查询》》》")
ip_info = Ips.get_or_none(Ips.id == bitgit_info1.ip_id)
# 替换为您的 API 密钥信息
api_key = bitgit_info1.apikey
secret_key = bitgit_info1.SecretKey
passphrase = 'hx123456'
proxies = {
'http': f'socks5h://{ip_info.ip_user}:{ip_info.ip_password}@{ip_info.ip}:{ip_info.ip_port}',
'https': f'socks5h://{ip_info.ip_user}:{ip_info.ip_password}@{ip_info.ip}:{ip_info.ip_port}'
}
params = {
"coin": "SOL",
"chain": "sol",
}
bitget_api = BitgetAPI(api_key, secret_key, passphrase, proxies)
userid_and_address = bitget_api.get_userid_and_address(params["coin"], params["chain"])
print(userid_and_address)
for i in userid_and_address:
BitgitAddress.get_or_create(
email=bitgit_info1.email,
uuid=i,
address=userid_and_address[i]
)
except:
pass
if __name__ == '__main__':
for bitgit_info in Bitgit.select().where(Bitgit.start.is_null()):
bitgit_address = BitgitAddress.select().where(BitgitAddress.email == bitgit_info.email)
if len(bitgit_address) == 21:
continue
main(bitgit_info)
time.sleep(1)

64
bitgit/接口/test3.py Normal file
View File

@@ -0,0 +1,64 @@
import requests
import time
import hmac
import hashlib
import base64
# 替换为您的 API 密钥信息
api_key = 'bg_de5d1fee9b211c0da479e7061aa5d45a'
secret_key = 'b94d9d470338ca84045ab1f6222d15954e7422de9e3a83a020f1b31446571b93'
passphrase = '040828cjj'
# API 请求的基础 URL
base_url = 'https://api.bitget.com'
# 获取当前时间戳(毫秒级)
timestamp = str(int(time.time() * 1000))
# 请求路径和参数
request_path = '/api/v2/spot/wallet/mpcRechargeAddress'
params = {
"coin": "SOL",
"chain": "sol",
# "subUid":"5557185666"
}
# 构造待签名字符串
query_string = '&'.join([f"{key}={value}" for key, value in params.items()])
prehash_string = timestamp + 'GET' + request_path + '?' + query_string
# 使用 HMAC SHA256 进行签名
signature = hmac.new(secret_key.encode('utf-8'), prehash_string.encode('utf-8'), hashlib.sha256).digest()
signature_base64 = base64.b64encode(signature).decode('utf-8')
# 设置请求头
headers = {
'ACCESS-KEY': api_key,
'ACCESS-SIGN': signature_base64,
'ACCESS-TIMESTAMP': timestamp,
'ACCESS-PASSPHRASE': passphrase,
'Content-Type': 'application/json',
'locale': 'zh-CN'
}
proxies = {
'http': f'socks5h://L2924:B928192@31.57.104.140:30000',
'https': f'socks5h://L2924:B928192@31.57.104.140:30000'
}
# 发送 GET 请求
url = f"{base_url}{request_path}?{query_string}"
response = requests.get(url, headers=headers, proxies=proxies)
print(response.json())
# 处理响应
if response.status_code == 200:
data = response.json()
if data['code'] == '00000':
deposit_address = data['data']['address']
print(f"您的 USDT (TRC20) 充值地址是:{deposit_address}")
else:
print(f"请求失败,错误信息:{data['msg']}")
else:
print(f"HTTP 请求失败,状态码:{response.status_code}")

35
bitgit/接口/text.py Normal file
View File

@@ -0,0 +1,35 @@
import requests
import time
import hashlib
import hmac
import json
# 设置基础信息
api_url = "https://api.bitget.com/api/v2/spot/account/subaccount-assets"
access_key = 'bg_de5d1fee9b211c0da479e7061aa5d45a' # 替换为你的ACCESS-KEY
secret_key = 'b94d9d470338ca84045ab1f6222d15954e7422de9e3a83a020f1b31446571b93' # 替换为你的SECRET_KEY
passphrase = '040828cjj' # 替换为你的PASSPHRASE
# 时间戳
timestamp = str(int(time.time() * 1000))
# 构造签名
message = timestamp + '\n' + 'GET' + '\n' + '/api/v2/spot/account/subaccount-assets' + '\n'
signature = hmac.new(secret_key.encode('utf-8'), message.encode('utf-8'), digestmod=hashlib.sha256).hexdigest()
# 设置请求头
headers = {
'ACCESS-KEY': access_key,
'ACCESS-SIGN': signature,
'ACCESS-PASSPHRASE': passphrase,
'ACCESS-TIMESTAMP': timestamp,
'locale': 'en-US',
'Content-Type': 'application/json'
}
# 发送GET请求
response = requests.get(api_url, headers=headers)
# 打印响应内容
print(response.status_code)
print(response.json())

View File

@@ -0,0 +1,64 @@
import requests
import time
import hmac
import hashlib
import base64
# 替换为您的 API 密钥信息
api_key = 'bg_de5d1fee9b211c0da479e7061aa5d45a'
secret_key = 'b94d9d470338ca84045ab1f6222d15954e7422de9e3a83a020f1b31446571b93'
passphrase = '040828cjj'
# API 请求的基础 URL
base_url = 'https://api.bitget.com'
# 获取当前时间戳(毫秒级)
timestamp = str(int(time.time() * 1000))
# 请求路径和参数
request_path = '/api/v2/spot/wallet/deposit-address'
params = {
"coin": "SOL",
"chain": "sol",
# "subUid":"5766250509"
}
# 构造待签名字符串
query_string = '&'.join([f"{key}={value}" for key, value in params.items()])
prehash_string = timestamp + 'GET' + request_path + '?' + query_string
# 使用 HMAC SHA256 进行签名
signature = hmac.new(secret_key.encode('utf-8'), prehash_string.encode('utf-8'), hashlib.sha256).digest()
signature_base64 = base64.b64encode(signature).decode('utf-8')
# 设置请求头
headers = {
'ACCESS-KEY': api_key,
'ACCESS-SIGN': signature_base64,
'ACCESS-TIMESTAMP': timestamp,
'ACCESS-PASSPHRASE': passphrase,
'Content-Type': 'application/json',
'locale': 'zh-CN'
}
proxies = {
'http': f'socks5h://L2924:B928192@31.57.104.140:30000',
'https': f'socks5h://L2924:B928192@31.57.104.140:30000'
}
# 发送 GET 请求
url = f"{base_url}{request_path}?{query_string}"
response = requests.get(url, headers=headers, proxies=proxies)
print(response.json())
# 处理响应
if response.status_code == 200:
data = response.json()
if data['code'] == '00000':
deposit_address = data['data']['address']
print(f"您的 USDT (TRC20) 充值地址是:{deposit_address}")
else:
print(f"请求失败,错误信息:{data['msg']}")
else:
print(f"HTTP 请求失败,状态码:{response.status_code}")