Create App.py
Browse files
App.py
CHANGED
@@ -1,91 +1,21 @@
|
|
1 |
-
|
2 |
-
|
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 |
-
|
10 |
-
from telebot import types
|
11 |
-
from bs4 import BeautifulSoup
|
12 |
-
import requests
|
13 |
-
from selenium import webdriver
|
14 |
-
import os
|
15 |
|
16 |
-
|
|
|
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 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
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)
|
|
|
1 |
+
python -m venv gradio-env
|
2 |
+
.\gradio-env\Scripts\activate
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
pip install gradio
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
import gradio as gr
|
7 |
+
print(gr.__version__)
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
import gradio as gr
|
11 |
|
12 |
+
def greet(name, intensity):
|
13 |
+
return "Hello " * intensity + name + "!"
|
14 |
+
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=greet,
|
17 |
+
inputs=["text", "slider"],
|
18 |
+
outputs=["text"],
|
19 |
+
)
|
20 |
+
|
21 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|