<jupyter_start><jupyter_text>Importation<jupyter_code>from bs import BS, Keys
from selenium import webdriver
import time, requests, json, pickle
b_driver = BS(
    webdriver.Firefox(executable_path="/home/tttienthinh/Documents/Programmation/Bash/StartupApp/driver/geckodriver"),
)
print("Make sure you have at least : ")
print(" 1 USDT in P2P transfert Binance to pay fees")
input("Enter when login is done : ")
b_driver.stake_page()
pickle.dump({"fees": 0}, open("data.pkl", "wb"))
pickle.load(open("data.pkl", "rb"))
file = json.load(open("data.json", "r"))
file
tokens = []
while True:
    token = input("Enter token Name or just Enter to run : ")
    token = token.upper().replace(" ", "")
    if token == "":
        break
    else:
        days = input("Days Staking periods : ")
        tokens.append({
            "TOKEN": token,
            "DAYS": days
        })
tokens
json.dump(tokens, open("data.json", "w"))
def binance():
    response = json.loads(requests.get(
        "https://www.binance.com/gateway-api/v1/friendly/pos/union?\
        pageSize=50&pageIndex=1&status=ALL").text)['data']
    result = []
    for item in response:
        for asset in item["projects"]:
            if not asset["sellOut"]:
                result.append({
                    "asset": asset["asset"],
                    "duration": asset["duration"],
                    "APY": str(round(float(asset["config"]["annualInterestRate"]) * 100, 2))
                })
    return result
binance()
print(f"I will look to stake \n {tokens}")
with open("data.txt", "r") as f:
    past_fees = float(f.read())
    f.close()
past_result = []
while True:
    print(time.asctime())
    result = binance()
    for data in result:
        if data not in past_result:
            asset = data['asset']
            duration = data['duration']
            apy = data['APY']
            print(f"Found new release \
            {asset} {duration} days {apy}% APY")
            
            if {'TOKEN': asset, 'DAYS': duration} in tokens:
                amount, fees = b_driver.stake()
                print(f"Staked Successfully !")
                done = b_driver.donation(fees + past_fees)
                if done:
                    with open("data.txt", "w") as f:
                        f.write("0")
                    past_fees = 0
                else:
                    with open("data.txt", "w") as f:
                        f.write(str(fees))
                    past_fees += fees 
            
    
    
    
    b_driver.stake_page()
    time.sleep(600 - (time.time() % 600)) # Executing every 10 minutes
    
"test".upper()
65 == "65"<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14446529080675422, 'fraction_numerical': 0.009380863039399626, 'mean_word_length': 2.032992036405006, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '335630', 'license': 'MIT', 'n_tokens_mistral': 855, 'n_tokens_neox': 817, 'n_words': 199, 'path': 'src/bs/04-main Staking.ipynb', 'repo_name': 'tttienthinh/BinanceSelenium', 'size': '2665'}