нужна задержка чтобы сайт прогрузился
prices = input().split()
prices = [int(x) for x in prices]
total_price = 0
cheap_prices = 0
for price in prices:
if price >= 500:
total_price += price - 100
else:
cheap_prices += price
if cheap_prices >= 500:
total_price += cheap_prices-100
else:
total_price += cheap_prices
print(total_price)
span
с классом price money-gold
загружаются динамически, не достанете обычным запросом на страницу.Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message.
on_message
добавить await bot.process_commands(message)
import requests
import re
import os
#...
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
documents = driver.find_elements_by_class_name("docext-container")
for document in documents:
# тут ищем родительский элемент, в нем есть нужный нам ID
document_id = document.find_element_by_xpath('..').get_attribute('data-documentation-id')
# в пейлод вписываем нужные данные от формы, и вставляем наш ID
payload='cr_documentation_action=download&documentation_id={}&email='.format(document_id)
# url для запроса - текущая страница
# ставим обязательно stream=True, чтобы файл не выкачивался сразу
r = requests.post(driver.current_url, headers=headers, data=payload, stream=True)
# название файлов всегда есть в заголовках запроса, response.headers
# поэтому берем их, видим в нужном ключе "attachment; filename*=UTF-8''hlw-shiptsy-ortodonticheskie-reg.pdf"
# ну и недолго думая дергаем регуляркой
document_name = re.search(r'\'\'(.+?\.pdf)', r.headers['Content-Disposition']).group(1)
# дальше уже нужно проверить наличие файла в папке
# я так понял путь до папки с загрузками в переменной path_registration_documents, так что:
if document_name in os.listdir(path_registration_documents):
print('Не новый')
else:
print('Новый док')
document.click()
if a and b == "Красный" or "красный":
if a == "Красный" or b == "красный":
if a == "Красный" or "красный" b == "Синий" or "синий" or a == "Синий" or "синий" b == "Красный" or "красный":
a = input("Введите первый основной цвет, Красный/Синий/Желтый: ").lower()
b = input("Введите второй основной цвет, Красный/Синий/Желтый: ").lower()
if a == "красный" and b == "синий" or a == "синий" and b == "красный":
print("Ваш вторичный цвет: Фиолетовый.")
if (a == "красный" and b == "синий") or (a == "синий" and b == "красный"):
(a = красный И b = синий) ИЛИ ЕСЛИ (a = синий И b = красный)
if a == "Красный" or "красный" b == "Синий" or "синий" or a == "Синий" or "синий" b == "Красный" or "красный":
a = Красный ИЛИ красный b = Синий ИЛИ синий ИЛИ a = Синий ИЛИ синий b = Красный ИЛИ красный
import os
# допустим все фото лежат в текущей директории в папке photos
photos_folder = os.path.join(os.getcwd(), ‘photos’)
if message.text == ‘photo’:
photos_to_send = []
for file in os.listdir(photos_folder):
if file.endswith(‘.jpg’): # можно убрать при желании
photo_path = os.join(photos_folder, file)
photos_to_send.append(telebot.types.InputMediaPhoto(open(photo_path, ‘rb’)))
if len(photos_to_send) == 10: # лимит на одно сообщение
bot.send_media_group(message.chat.id, media=photos_to_send)
photos_to_send.clear()
# дослать остатки, которых меньше 10, если есть
if photos_to_send:
bot.send_media_group(message.chat.id, media=photos_to_send)