jeduardogruiz
commited on
Commit
•
763870f
1
Parent(s):
e1f3114
App.py
Browse files
App.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import telebot
|
2 |
+
from telebot import types
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
import requests
|
5 |
+
from selenium import webdriver
|
6 |
+
import os
|
7 |
+
bot = telebot.TeleBot('1568111312:AAFDLr5-uhe-xdNJDKCk0CM64FOY55bROFA')
|
8 |
+
|
9 |
+
import telebot
|
10 |
+
from telebot import types
|
11 |
+
from bs4 import BeautifulSoup
|
12 |
+
import requests
|
13 |
+
from selenium import webdriver
|
14 |
+
import os
|
15 |
+
|
16 |
+
bot = telebot.TeleBot('1568111312:AAFDLr5-uhe-xdNJDKCk0CM64FOY55bROFA')
|
17 |
+
|
18 |
+
@bot.message_handler(commands=['start'])
|
19 |
+
def start(message):
|
20 |
+
# Кнопки для бота
|
21 |
+
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
|
22 |
+
btn1 = types.KeyboardButton("bitcoin")
|
23 |
+
btn2 = types.KeyboardButton
|
24 |
+
|
25 |
+
|
26 |
+
@bot.message_handler(commands=['start'])
|
27 |
+
def start(message):
|
28 |
+
#Кнопки для бота
|
29 |
+
markup = types.ReplyKeyboardMarkup(resize_keyboard = True,row_width=2)
|
30 |
+
btn1 = types.KeyboardButton("bitcoin")
|
31 |
+
btn2 = types.KeyboardButton("ethreum")
|
32 |
+
btn3 = types.KeyboardButton("xrp")
|
33 |
+
btn4 = types.KeyboardButton("cardano")
|
34 |
+
markup.add(btn1,btn2,btn3,btn4)
|
35 |
+
send_mess = f"<b>Здравствуйте {message.from_user.first_name}</b>\nНазвание криптавалюты"
|
36 |
+
bot.send_message(message.chat.id, send_mess,parse_mode = 'html',reply_markup=markup)
|
37 |
+
@bot.message_handler(content_types=['text'])
|
38 |
+
def mess(message):
|
39 |
+
final_message = ""
|
40 |
+
get_message_bot = message.text.strip().lower()
|
41 |
+
if get_message_bot == "bitcoin":
|
42 |
+
Bitcoin = 'https://ru.investing.com/indices/investing.com-btc-usd'
|
43 |
+
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'}
|
44 |
+
full_page = requests.get(Bitcoin,headers = header)
|
45 |
+
soup = BeautifulSoup(full_page.content,'html.parser')
|
46 |
+
convert = soup.findAll("span",{"class": "arial_26 inlineblock pid-1057391-last","id":"last_last"})
|
47 |
+
final_message = f"1 Bitcoin = {convert[0].text} $."
|
48 |
+
driver = webdriver.Firefox()
|
49 |
+
driver.get('https://ru.tradingview.com/chart/?symbol=BITSTAMP%3ABTCUSD/wd/hub')
|
50 |
+
driver.save_screenshot("bitcoin.png")
|
51 |
+
driver.quit()
|
52 |
+
bot.send_photo(message.chat.id,open('bitcoin.png','rb'))
|
53 |
+
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'bitcoin.png')
|
54 |
+
os.remove(path)
|
55 |
+
elif get_message_bot == "ethreum":
|
56 |
+
Ethreum = 'https://ru.investing.com/crypto/ethereum/eth-usd?cid=997650'
|
57 |
+
header_1 = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'}
|
58 |
+
full_page_1 = requests.get(Ethreum, headers=header_1)
|
59 |
+
soup_1 = BeautifulSoup(full_page_1.content, 'html.parser')
|
60 |
+
convert_1 = soup_1.findAll("span", {"class": "arial_26 inlineblock pid-997650-last","id":"last_last"})
|
61 |
+
final_message = f"1 Ethreum = {convert_1[0].text} $"
|
62 |
+
driver = webdriver.Firefox()
|
63 |
+
driver.get('https://ru.tradingview.com/chart/?symbol=BITSTAMP%3AETHUSD')
|
64 |
+
driver.save_screenshot("ethreum.png")
|
65 |
+
bot.send_photo(message.chat.id, open('ethreum.png', 'rb'))
|
66 |
+
elif get_message_bot == "xrp":
|
67 |
+
XRP = 'https://ru.investing.com/crypto/xrp/xrp-usd'
|
68 |
+
header_2 = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'}
|
69 |
+
full_page_2 = requests.get(XRP, headers=header_2)
|
70 |
+
soup_2 = BeautifulSoup(full_page_2.content, 'html.parser')
|
71 |
+
convert_2 = soup_2.findAll("span", {"class": "arial_26 inlineblock pid-1118146-last","id":"last_last"})
|
72 |
+
final_message = f"1 XRP = {convert_2[0].text} $"
|
73 |
+
driver = webdriver.Firefox()
|
74 |
+
driver.get('https://ru.tradingview.com/chart/?symbol=BITSTAMP%3AXRPUSD')
|
75 |
+
driver.save_screenshot("xrp.png")
|
76 |
+
bot.send_photo(message.chat.id, open('xrp.png', 'rb'))
|
77 |
+
elif get_message_bot == "cardano":
|
78 |
+
Cardano = 'https://ru.investing.com/crypto/cardano/ada-usd'
|
79 |
+
header_3 = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'}
|
80 |
+
full_page_3 = requests.get(Cardano, headers=header_3)
|
81 |
+
soup_3 = BeautifulSoup(full_page_3.content, 'html.parser')
|
82 |
+
convert_3 = soup_3.findAll("span", {"class": "arial_26 inlineblock pid-1073899-last","id":"last_last"})
|
83 |
+
final_message = f"1 Cardano = {convert_3[0].text} $"
|
84 |
+
driver = webdriver.Firefox()
|
85 |
+
driver.get('https://ru.tradingview.com/chart/?symbol=BITFINEX%3AADAUSD')
|
86 |
+
element = driver.save_screenshot("cardano.png")
|
87 |
+
bot.send_photo(message.chat.id, open('cardano.png', 'rb'))
|
88 |
+
else:
|
89 |
+
final_message = f"<u>Курс данной криптовалюты отсутствует в боте</u>"
|
90 |
+
bot.send_message(message.chat.id,final_message,parse_mode="html")
|
91 |
+
bot.polling(none_stop=True)
|