#
numbers = items.keys()
index_current = numbers.index(number_current)
if index_current > 0:
number_prev = numbers[index_current-1]
else:
number_prev = numbers[-1]
if index_current < len(numbers)-1:
number_next = numbers[index_current+1]
else:
number_next = numbers[0]
next =InlineKeyboardButton(text= 'Следующий',callback_data= f'item:{number_next}')
previous =InlineKeyboardButton(text= 'Предыдущий',callback_data= f'item:{number_prev}')
add = InlineKeyboardButton(text= 'Добавить в корзину',callback_data= f'add:{number_current}')
...
if call.data.startswith('item:'):
number_current = call.data[5:]
show_this_item_to_user
if call.data.startswith('add:'):
number_current = call.data[4:]
add_this_item_to_basket
print(soup.find('span', {'class': 'searchBar__mediaTabTextValue searchBar__mediaTabTotal'}).get_text())
>>> 75
Нужно рабочее решение !!!!
не принимаю и даю жалобу.
хотя класс такой на странице есть и прогружается он сразу
wss://data.tradingview.com/socket.io/websocket?from=symbols%2FBTCUSD%2F&date=2021_05_06-10_12
class emp:
name='Harsh'
salary='25000'
def show(self):
print (self.name)
print (self.salary)
e1 = emp()
# Use getattr instead of e1.name
print (getattr(e1,'name'))
# returns true if object has attribute
print (hasattr(e1,'name'))
# sets an attribute
setattr(e1,'height',152)
# returns the value of attribute name height
print (getattr(e1,'height'))
# delete the attribute
delattr(emp,'salary')
>>> import time
>>> time.time()
1620233838.275895
>>> current_time = int(time.time())
>>> current_time
1620233873
>>> expire_date = current_time + 7 * 24 * 60 * 60
# прибавили число равное 7 суткам в секундах
>>> expire_date
1620838673
# время жизни = текущее время + 7дней
import telebot
from telebot import types
import re
items = ['A el', 'B el', 'C el', 'D el']
def generate_markup(pages_count, current_page=0):
markup = types.InlineKeyboardMarkup()
for i in range(pages_count):
markup.add(types.InlineKeyboardButton(i+1, callback_data='page_{}'.format(i)))
btn_back = types.InlineKeyboardButton('Назад', callback_data='page_{}'.format(current_page-1))
btn_forward = types.InlineKeyboardButton('Вперед', callback_data='page_{}'.format(current_page+1))
if current_page == pages_count-1:
markup.add(btn_back)
elif current_page == 0:
markup.add(btn_forward)
else:
markup.row(btn_back, btn_forward)
return markup
@bot.message_handler(commands=['start'])
def send_start(message):
bot.send_message(message.chat.id, items[0], reply_markup=generate_markup(len(items)))
@bot.callback_query_handler(func = lambda call: re.match(r'page_\d+$', call.data))
def callback_query(call):
page = int(re.match(r'page_(\d+)$', call.data).group(1))
bot.edit_message_text(items[page], call.message.chat.id, call.message.message_id, reply_markup=generate_markup(len(items), page))
for dict_ in data.values():
for key, value in dict_.items():
print(f"{key}: {value}"