-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject-kucoin.py
More file actions
126 lines (91 loc) · 5.11 KB
/
project-kucoin.py
File metadata and controls
126 lines (91 loc) · 5.11 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
import time
# 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-u4meas")
search_number = driver.find_elements(By.CLASS_NAME, "css-u5tz8w")
binance_data = []
for element, number in zip(search_name, search_number):
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}%"
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)
return binance_data_frame
def coinbase():
driver.get("https://www.coinbase.com/earn")
print(f'\nCoinbase: {driver.title} \n')
search_name = driver.find_elements(By.CLASS_NAME, "cds-typographyResets-t1xhpuq2.cds-label2-l5adacs.cds-foregroundMuted-f1vw1sy6.cds-transition-txjiwsi.cds-start-s1muvu8a.cds-0_5-_1oczfiq")
search_number = driver.find_elements(By.CLASS_NAME, "cds-typographyResets-t1xhpuq2.cds-textInherit-t1yzihzw.cds-positive-p1xe9yrm.cds-transition-txjiwsi.cds-start-s1muvu8a.cds-link--container")
coinbase_data = []
for element, number in zip(search_name, search_number):
coinbase_data.append({"Coin": element.text, "Reward": number.text})
coinbase_data_frame = pd.DataFrame(coinbase_data)
return coinbase_data_frame
#If we wanted more coins we would have to click the next button
#link = driver.find_element(By.CLASS_NAME, "cds-interactable-i9xooc6.cds-transparentChildren-tnzgr0o.cds-focusRing-fd371rq.cds-transparent-tlx9nbb.cds-button-b18qe5go.cds-scaledDownState-sxr2bd6.cds-flex-f1g67tkn.cds-center-ca5ylan.cds-center-czxavit.cds-iconButton-i1804idl")
#link.click()
def kucoin():
driver.get("https://www.bybit.com/en/earn/savings/")
print(f'\nKucoin: {driver.title} \n')
search_name = driver.find_elements(By.CLASS_NAME, "ant-col.CoinGroupListItem_coin__RyFvf")
search_number = driver.find_elements(By.CLASS_NAME, "CoinGroupListItem_value__3gWJ0")
kucoin = []
# Removing "Platform Rewards" from the list using a list comprehension
cleaned_elements = []
for element in search_number:
if element.text != "Flexible/Fixed" and element.text != "Select" and element.text != "Flexible":
cleaned_elements.append(element.text)
for element, number in zip(search_name, cleaned_elements):
element = element.text.replace("\nPlatform Rewards", "")
kucoin.append({"Coin": element, "Reward": number})
kucoin_data_frame = pd.DataFrame(kucoin)
return kucoin_data_frame
#If we wanted more coins we would have to click the next button
#link = driver.find_element(By.CLASS_NAME, "cds-interactable-i9xooc6.cds-transparentChildren-tnzgr0o.cds-focusRing-fd371rq.cds-transparent-tlx9nbb.cds-button-b18qe5go.cds-scaledDownState-sxr2bd6.cds-flex-f1g67tkn.cds-center-ca5ylan.cds-center-czxavit.cds-iconButton-i1804idl")
#link.click()
def bitstamp():
driver.get("https://www.bitstamp.net/crypto-lending/")
print(f'\nBitstamp: {driver.title} \n')
search_name = driver.find_elements(By.CLASS_NAME, "currency__name")
search_number = driver.find_elements(By.CLASS_NAME, "text--positive.text--medium")
# Filter out elements with empty text
non_empty_elements = [element for element in search_number if element.text.strip()]
bitstamp_data = []
for element, number in zip(search_name, non_empty_elements):
bitstamp_data.append({"Coin": element.text, "Reward": number.text})
coinbase_data_frame = pd.DataFrame(bitstamp_data)
return coinbase_data_frame
def replace_coin_name(df, coin_mapping):
df['Coin'] = df['Coin'].replace(coin_mapping, regex=True)
return df
coin_mapping = {
'Bitcoin Cash': 'BCH',
'Bitcoin': 'BTC',
'Ether': 'ETH',
'Chainlink': 'LINK',
'Litecoin': 'LTC',
'Tether': 'USDT'
}
kucoin_data_frame = kucoin()
#binance_data_frame = binance()
#bitstamp_data_frame = bitstamp()
#bitstamp_data_frame = replace_coin_name(bitstamp_data_frame, coin_mapping)
print(kucoin_data_frame)