-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinance.py
More file actions
43 lines (34 loc) · 1.73 KB
/
binance.py
File metadata and controls
43 lines (34 loc) · 1.73 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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import pandas as pd
# path to chromedriver.exe
chromedriver_path = "C:\\Program Files (x86)\\chromedriver.exe"
# Set up Chrome options and service
chrome_options = Options()
service = Service(executable_path=chromedriver_path)
# Initialize the driver with the service and options
driver = webdriver.Chrome(service=service, options=chrome_options)
def binance():
binance_driver = driver.get("https://www.binance.com/en/earn/simple-earn")
print(f'\nBinance: {driver.title} \n')
search_name = driver.find_elements(By.CLASS_NAME, "css-1atjgtt")
search_number = driver.find_elements(By.CLASS_NAME, "css-1000w8k")
binance_data = []
for element, number in zip(search_name, search_number):
print(f'coin: {element.text} reward: {number.text}')
if "+" in number.text: #If they ofer some special bonus sum the Reward.
string = number.text
percentages = [float(p.replace('%', '')) for p in string.split('\n') if '%' in p]
# Calculating the total sum of the percentages
total_percentage = round(sum(percentages),2)
total_percentage_str = f"{total_percentage}%"
print(f'coisdfsdfsfn: {element.text} reward: {total_percentage_str}')
binance_data.append({"Coin": element.text, "Reward": total_percentage_str})
else:
binance_data.append({"Coin": element.text, "Reward": number.text})
binance_data_frame = pd.DataFrame(binance_data)
print(binance_data_frame)
return binance_data_frame
binance()