import requests from base_class import BaseVariableFunction from base_class import * baseclass = BaseVariableFunction(__file__) old_print = print def timestamped_print(*args, **kwargs): old_print(datetime.datetime.utcnow().replace( microsecond=0), *args, **kwargs) print = timestamped_print print('\n'*5) print(f"{'{:<6}'.format('ENTER')} {baseclass.scriptfilename} ----------------NOTE-----------NOTE---------------") url = "https://solana-mainnet.g.alchemy.com/v2/WLI0ohbUlvbsJVmoIvB1wTSwUA8qP5qS" getBalance_payload = { "id": 1, "jsonrpc": "2.0", "method": "getBalance", "params": [] } headers = { "accept": "application/json", "content-type": "application/json" } df = pd.read_excel( baseclass.dalao_merge_defined_path / f"ori_merge_defined.xlsx", dtype=object) df= df.astype({ "eth":int }) df = df.drop_duplicates(subset=["dalaoaddress"]) df =df.reset_index(drop=True) df_not_getbalance =df[ df["eth"]==-1] arr_str_dalaoaddress = df_not_getbalance['dalaoaddress'].tolist() for idx , str_dalaoaddress in enumerate(arr_str_dalaoaddress): print(f"str_dalaoaddress={str_dalaoaddress}") getBalance_payload["params"] = [str_dalaoaddress] response = requests.post(url, json=getBalance_payload, headers=headers) if response.status_code != 200: continue response_data = response.json() eth_value = response_data["result"]["value"] / (10**9) df.loc[ df["dalaoaddress"] ==str_dalaoaddress , "eth"] = eth_value print(f"str_dalaoaddress={str_dalaoaddress} eth_value={eth_value}") if idx%5==0: df.to_excel( baseclass.dalao_merge_defined_path / f"ori_merge_defined.xlsx", index=False) df.to_excel( baseclass.dalao_merge_defined_path / f"ori_merge_defined.xlsx", index=False)