1
1
import requests
2
2
from bs4 import BeautifulSoup
3
+ from WarrenBuffetBot .core_class .core_class import Parsing
3
4
4
5
5
- class Cryptocurrencies :
6
- headers = {
7
- 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36' }
8
-
9
- def __init__ (self , link_to_cryptocurrency , html_class_parsing , name_cryptocurrency ):
10
- self .link_to_cryptocurrency = link_to_cryptocurrency
11
- self .html_class_parsing = html_class_parsing
12
- self .name_cryptocurrency = name_cryptocurrency
13
-
14
- def get_cryptocurrency_value (self ):
6
+ class Cryptocurrencies (Parsing ):
7
+ def get_data (self ):
15
8
# Парсим всю страницу
16
- full_page = requests .get (self .link_to_cryptocurrency , headers = self .headers )
9
+ full_page = requests .get (self .link , headers = self .headers )
17
10
18
11
# Разбираем через BeautifulSoup
19
12
soup = BeautifulSoup (full_page .content , 'html.parser' )
20
13
21
14
# Получаем нужное для нас значение и возвращаем его
22
15
convert = soup .findAll ("span" , self .html_class_parsing )
23
- return f'{ self .name_cryptocurrency } { convert [0 ].text } '
16
+ return f'{ self .name } { convert [0 ].text } '
24
17
25
18
bitcoin = Cryptocurrencies ('https://ru.investing.com/crypto/bitcoin' , html_class_parsing = {'class' : 'pid-1057391-last' },
26
- name_cryptocurrency = 'Bitcoin ➡ ' )
19
+ name = 'Bitcoin ➡ ' )
27
20
ethereum = Cryptocurrencies ('https://ru.investing.com/crypto/ethereum/eth-usd' , html_class_parsing = {'class' : 'text-2xl' },
28
- name_cryptocurrency = 'Ethereum ➡ ' )
21
+ name = 'Ethereum ➡ ' )
29
22
litecoin = Cryptocurrencies ('https://ru.investing.com/crypto/litecoin' , html_class_parsing = {'class' : 'pid-1061445-last' },
30
- name_cryptocurrency = 'Litecoin ➡ ' )
23
+ name = 'Litecoin ➡ ' )
31
24
cardano = Cryptocurrencies ('https://ru.investing.com/crypto/cardano/ada-usd' , html_class_parsing = {'class' : 'text-2xl' },
32
- name_cryptocurrency = 'Cardano ➡ ' )
25
+ name = 'Cardano ➡ ' )
33
26
xrp = Cryptocurrencies ('https://ru.investing.com/crypto/xrp/xrp-usd' , html_class_parsing = {'class' : 'text-2xl' },
34
- name_cryptocurrency = 'XRP ➡ ' )
27
+ name = 'XRP ➡ ' )
35
28
doge = Cryptocurrencies ('https://ru.investing.com/crypto/dogecoin/doge-usd' , html_class_parsing = {'class' : 'text-2xl' },
36
- name_cryptocurrency = 'DOGE ➡ ' )
29
+ name = 'DOGE ➡ ' )
37
30
bnb = Cryptocurrencies ('https://ru.investing.com/crypto/binance-coin' , html_class_parsing = {'class' : 'pid-1061448-last' },
38
- name_cryptocurrency = 'BNB ➡ ' )
31
+ name = 'BNB ➡ ' )
39
32
tether = Cryptocurrencies ('https://ru.investing.com/crypto/tether' , html_class_parsing = {'class' : 'pid-1061453-last' },
40
- name_cryptocurrency = 'Tether ➡ ' )
33
+ name = 'Tether ➡ ' )
41
34
solana = Cryptocurrencies ('https://ru.investing.com/crypto/solana' , html_class_parsing = {'class' : 'pid-1177183-last' },
42
- name_cryptocurrency = 'Solana ➡ ' )
35
+ name = 'Solana ➡ ' )
43
36
luna = Cryptocurrencies ('https://ru.investing.com/crypto/terra-luna' , html_class_parsing = {'class' : 'pid-1177187-last' },
44
- name_cryptocurrency = 'Luna ➡ ' )
37
+ name = 'Luna ➡ ' )
45
38
uniswap = Cryptocurrencies ('https://ru.investing.com/crypto/uniswap' , html_class_parsing = {'class' : 'pid-1177189-last' },
46
- name_cryptocurrency = 'UniSwap ➡ ' )
39
+ name = 'UniSwap ➡ ' )
47
40
polkadot = Cryptocurrencies ('https://ru.investing.com/crypto/polkadot-new' , html_class_parsing = {'class' : 'pid-1177185-last' },
48
- name_cryptocurrency = 'Polkadot ➡ ' )
41
+ name = 'Polkadot ➡ ' )
49
42
avalanche = Cryptocurrencies ('https://ru.investing.com/crypto/avalanche' , html_class_parsing = {'class' : 'pid-1177190-last' },
50
- name_cryptocurrency = 'Avalanche ➡ ' )
43
+ name = 'Avalanche ➡ ' )
51
44
chainlink = Cryptocurrencies ('https://ru.investing.com/crypto/chainlink' , html_class_parsing = {'class' : 'pid-1061794-last' },
52
- name_cryptocurrency = 'Chainlink ➡ ' )
45
+ name = 'Chainlink ➡ ' )
53
46
tron = Cryptocurrencies ('https://ru.investing.com/crypto/tron' , html_class_parsing = {'class' : 'pid-1061450-last' },
54
- name_cryptocurrency = 'Tron ➡ ' )
47
+ name = 'Tron ➡ ' )
55
48
shiba = Cryptocurrencies ('https://ru.investing.com/crypto/shiba-inu' , html_class_parsing = {'class' : 'pid-1177506-last' },
56
- name_cryptocurrency = 'SHIBA ➡ ' )
49
+ name = 'SHIBA ➡ ' )
0 commit comments