From 3aa7bb3d7d50041ec837fb170c96ddebada9433f Mon Sep 17 00:00:00 2001 From: iOnTuMuCTi <124861991+iOnTuMuCTi@users.noreply.github.com> Date: Thu, 20 Apr 2023 11:05:35 +0300 Subject: [PATCH 01/43] Update BOT_TG.py --- Задания/task1/Sukhanov/BOT_TG.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py index 8b13789..4972205 100644 --- a/Задания/task1/Sukhanov/BOT_TG.py +++ b/Задания/task1/Sukhanov/BOT_TG.py @@ -1 +1,39 @@ +import telebot +import psycopg2 +import config +from telebot import types +import random +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') + +cursor = connection.cursor() + +sel_query = """SELECT * FROM public.parser""" +cursor.execute(sel_query) +array = list(cursor.fetchall()) + +bot = telebot.TeleBot('6293063008:AAEFscB5LEjxC_4irrcgT-z6Eb0NXYOxZng') +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Рандомный продукт") + item2 = types.KeyboardButton("Повтори!") + markup.add(item1) + markup.add(item2) + bot.send_message(m.chat.id, + '"Рандомный продукт" - для получения карточки товара\n "Повтори!" - для повторения сообщений.', + reply_markup=markup) + + +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if (message.text.strip() == 'Рандомный продукт'): + i = random.choice(array) + ans = f'Название: {i[1]}\nЦена: {i[2]}\nРейтинг: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + elif (message.text.strip() == 'Повтори!'): + bot.send_message(message.chat.id, 'Ввод: ' + message.text) + + +bot.polling(none_stop=True, interval=0) From 8fc1cf3f164a173a36aed65e784193f1fdbe0b55 Mon Sep 17 00:00:00 2001 From: Harutyun Date: Thu, 20 Apr 2023 11:06:26 +0300 Subject: [PATCH 02/43] parser with database --- Задания/task1/Garanyan/tgbot.py | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Задания/task1/Garanyan/tgbot.py diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py new file mode 100644 index 0000000..91ffddf --- /dev/null +++ b/Задания/task1/Garanyan/tgbot.py @@ -0,0 +1,47 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', + password='Q1w2e3r4') +cursor = connection.cursor() +try: + sel_query = """SELECT * FROM public.food""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import tableCreator + + sel_query = """SELECT * FROM public.food""" + cursor.execute(sel_query) + +array = list(cursor.fetchall()) + +bot = telebot.TeleBot('841097550:AAFc5MoFRivTEfv-gOSJctqH53NfYMTKpCc') + + +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Хот-доги и соусы!") + item2 = types.KeyboardButton("Повтори!") + markup.add(item1) + markup.add(item2) + bot.send_message(m.chat.id, + '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n "Повтори!" - для повторения сообщений.', + reply_markup=markup) + + +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if (message.text.strip() == 'Хот-доги и соусы!'): + i = random.choice(array) + ans = f'Название: {i[1]}\nЦена: {i[2]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[3], 'rb')) + elif (message.text.strip() == 'Повтори!'): + bot.send_message(message.chat.id, 'Ввод: ' + message.text) + + +bot.polling(none_stop=True, interval=0) \ No newline at end of file From 0981a7b70b4c1c3443bbb196a1615e34631e1f08 Mon Sep 17 00:00:00 2001 From: Harutyun Date: Thu, 20 Apr 2023 11:07:53 +0300 Subject: [PATCH 03/43] bot telegram 1 popytka --- Задания/task1/Garanyan/tgbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py index 91ffddf..2b47151 100644 --- a/Задания/task1/Garanyan/tgbot.py +++ b/Задания/task1/Garanyan/tgbot.py @@ -2,7 +2,7 @@ import telebot import psycopg2 from telebot import types import random - +#hello connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() From 67ff96b8636e5aa4c70ee31dbd81b78f2ac4b732 Mon Sep 17 00:00:00 2001 From: Sanich777 Date: Thu, 20 Apr 2023 11:21:46 +0300 Subject: [PATCH 04/43] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D1=81=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=20=D0=B1=D0=B4=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Kulikov/db_parsV2.0.py | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Задания/task1/Kulikov/db_parsV2.0.py diff --git a/Задания/task1/Kulikov/db_parsV2.0.py b/Задания/task1/Kulikov/db_parsV2.0.py new file mode 100644 index 0000000..2892449 --- /dev/null +++ b/Задания/task1/Kulikov/db_parsV2.0.py @@ -0,0 +1,54 @@ +from bs4 import BeautifulSoup +from selenium.webdriver import Chrome +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +import time +import wget +import psycopg2 +import re +s = Service('C:\Users\Alex\PycharmProjects\pythonProject\chromedriver.exe') +browser = webdriver.Chrome(service=s) +browser.get('https://music.yandex.ru/chart') +time.sleep (1) +html_text = browser.page_source +soup = BeautifulSoup(html_text, 'lxml') +Трек=soup.find_all('a', class_='d-track__title deco-link deco-link_stronger') +Длительность=soup.find_all('div', class_='d-track__info d-track__nohover') +Автор=soup.find_all('span', class_='d-track__artists') +Картинки=soup.find_all('img', class_='entity-cover__image deco-pane') +str_Картинки=[] +for i in range(len(Картинки)): + str_Картинки.append(Картинки[i]) +str_Картинки=str(str_Картинки) +str_Картинки=re.findall(r'src="(.*?)"',str_Картинки) +for i in range(len(str_Картинки)): + str_Картинки[i]='https:'+str_Картинки[i] +#for i in range(len(str_cartinki)): + #wget.download(str_cartinki[i], 'TOP'+str((i+1))+'.jpeg') + + +connection = psycopg2.connect(dbname = 'dbdata', + user='postgres', password='Q1w2e3r4', + host='localhost') +cursor=connection.cursor() +creat_table="""CREATE TABLE music + (id serial primary key, "Трек" varchar(100), + "Длительность" varchar(100), + "Автор" varchar(100), + "Картинки" varchar(100))""" +cursor.execute(creat_table) +connection.commit() +for Трек, Длительность, Автор, Картинки in zip(Трек, Автор, Длительность, Картинки): + qwery=f"""INSERT INTO public.music( + Трек, Длительность, Автор, Картинки) + VALUES + ('{Трек.text}','{Длительность.text}','{Автор.text}', '{Картинки.text}' )""" + cursor.execute(qwery) + connection.commit() +for i in range(1,len(str_Картинки)+1): + puti = r'C:\papkta' + str(i) + '.jpeg' + qwery=f"""UPDATE public.music + SET Картинки='{puti}' + WHERE id={i}""" + cursor.execute(qwery) + connection.commit() \ No newline at end of file From 71d55083478f3642d2245e232f9041bd12d8d3a5 Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:05:34 +0300 Subject: [PATCH 05/43] Create folder for tgBot This is the file needed to create the folder --- Задания/task1/Epifanov/folder for tgBot | 1 + 1 file changed, 1 insertion(+) create mode 100644 Задания/task1/Epifanov/folder for tgBot diff --git a/Задания/task1/Epifanov/folder for tgBot b/Задания/task1/Epifanov/folder for tgBot new file mode 100644 index 0000000..7a5cafb --- /dev/null +++ b/Задания/task1/Epifanov/folder for tgBot @@ -0,0 +1 @@ +folder-file From 92c06f71a03cbc874d09823d44aa1939251bbbad Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:07:22 +0300 Subject: [PATCH 06/43] Delete folder for tgBot --- Задания/task1/Epifanov/folder for tgBot | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Задания/task1/Epifanov/folder for tgBot diff --git a/Задания/task1/Epifanov/folder for tgBot b/Задания/task1/Epifanov/folder for tgBot deleted file mode 100644 index 7a5cafb..0000000 --- a/Задания/task1/Epifanov/folder for tgBot +++ /dev/null @@ -1 +0,0 @@ -folder-file From e8bb76c772eac88de04253044d37bffe04c064a3 Mon Sep 17 00:00:00 2001 From: VladEpifanov Date: Sun, 23 Apr 2023 10:17:19 +0300 Subject: [PATCH 07/43] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Epifanov/WWFile.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Задания/task1/Epifanov/WWFile.py diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/WWFile.py new file mode 100644 index 0000000..598f98f --- /dev/null +++ b/Задания/task1/Epifanov/WWFile.py @@ -0,0 +1,22 @@ +import psycopg2 + +connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') +cursor = connection.cursor() + +def edit(Col, N, NN, value):#Функция внесения изменений и сортировки + upd_query = f'''UPDATE Parse SET {Col} = '{NN}' WHERE {Col} = '{N}' ''' + cursor.execute(upd_query) + ord_query = f'''SELECT * FROM public.parse order by {value};''' + cursor.execute(ord_query) + connection.commit() + +edit('Name', 'Ирисы небесно-голубого цвета', 'Ирисы', 'ID') + +#print(cursor.fetchall()) - для проверки + +def select(ID): + s_query = f'''SELECT * FROM public.Parse where ID = {ID}''' + cursor.execute(s_query) + return cursor.fetchone() + +#print(select(44)) - для проверки From d6b3ab0894d85b65b9c7e735474ec3b5f027521f Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:21:38 +0300 Subject: [PATCH 08/43] Delete WWFile.py --- Задания/task1/Epifanov/WWFile.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Задания/task1/Epifanov/WWFile.py diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/WWFile.py deleted file mode 100644 index 598f98f..0000000 --- a/Задания/task1/Epifanov/WWFile.py +++ /dev/null @@ -1,22 +0,0 @@ -import psycopg2 - -connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') -cursor = connection.cursor() - -def edit(Col, N, NN, value):#Функция внесения изменений и сортировки - upd_query = f'''UPDATE Parse SET {Col} = '{NN}' WHERE {Col} = '{N}' ''' - cursor.execute(upd_query) - ord_query = f'''SELECT * FROM public.parse order by {value};''' - cursor.execute(ord_query) - connection.commit() - -edit('Name', 'Ирисы небесно-голубого цвета', 'Ирисы', 'ID') - -#print(cursor.fetchall()) - для проверки - -def select(ID): - s_query = f'''SELECT * FROM public.Parse where ID = {ID}''' - cursor.execute(s_query) - return cursor.fetchone() - -#print(select(44)) - для проверки From a8a81dd41c63d1ca0340b8f29642d416e88e4b9c Mon Sep 17 00:00:00 2001 From: VladEpifanov Date: Sun, 23 Apr 2023 10:27:31 +0300 Subject: [PATCH 09/43] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Epifanov/{WWFile.py => wwfuncs.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Задания/task1/Epifanov/{WWFile.py => wwfuncs.py} (100%) diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/wwfuncs.py similarity index 100% rename from Задания/task1/Epifanov/WWFile.py rename to Задания/task1/Epifanov/wwfuncs.py From c1cc125a9664caf25cbb04027a6b764dafa1f209 Mon Sep 17 00:00:00 2001 From: VladEpifanov Date: Sun, 23 Apr 2023 10:33:00 +0300 Subject: [PATCH 10/43] =?UTF-8?q?=D0=9A=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=91=D0=94=20+=20=D0=B7=D0=B0=D0=B4=D0=B5=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B8=D0=B7=20wwfuncs.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tgBot(try-exc-finally+usage of func-s.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py new file mode 100644 index 0000000..47b402d --- /dev/null +++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py @@ -0,0 +1,63 @@ +#Небольшое предисловие: кнопки item1, item2 и item3 похожи по своему функционалу, однако между ними есть разница в реализации - item3 реализована через функцию, прописанную в доп.файле +import telebot +import psycopg2 +from telebot import types +import random +from wwfuncs import select #импорт функции из другого файла + +connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') +cursor = connection.cursor() + +try: + s_query = """SELECT * FROM public.parse""" + cursor.execute(s_query) +except psycopg2.errors.UndefinedTable: #рассматриваем случай, когда таблицы нет + connection.rollback() #возвращаемся "на действие назад" + import FHWDB #создаём и заполняем таблицу, если её не существовало ранее + connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') + cursor = connection.cursor() + s_query = '''SELECT * FROM public.parse''' + cursor.execute(s_query) +finally: + arr = list(cursor.fetchall()) + +bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw') + +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста") + item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста") + item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста") + item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных") + markup.add(item1) + markup.add(item2) + markup.add(item3) + markup.add(item4) + bot.send_message(m.chat.id, + '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.', + reply_markup=markup) + +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"): + i = random.choice(arr) + a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n' + bot.send_message(message.chat.id, a1) + elif (message.text.strip() == "Хочу картинку любых цветов, пожалуйста"): + i = random.choice(arr) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + elif (message.text.strip() == "Хочу информацию о предложении дня, пожалуйста"): + j = random.randint(1, 61) + i = list(select(j)) + a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n' + bot.send_message(message.chat.id, "Предложение дня:\n") + bot.send_message(message.chat.id, a1) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + else: + bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ") + +bot.polling(none_stop=True, interval=0) + +cursor.close() +connection.close() \ No newline at end of file From effcf0e8ea93284673467f2d1bb15da87f601830 Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:30:54 +0300 Subject: [PATCH 11/43] Delete tgBot(try-exc-finally+usage of func-s.py --- .../tgBot(try-exc-finally+usage of func-s.py | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py deleted file mode 100644 index 47b402d..0000000 --- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py +++ /dev/null @@ -1,63 +0,0 @@ -#Небольшое предисловие: кнопки item1, item2 и item3 похожи по своему функционалу, однако между ними есть разница в реализации - item3 реализована через функцию, прописанную в доп.файле -import telebot -import psycopg2 -from telebot import types -import random -from wwfuncs import select #импорт функции из другого файла - -connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') -cursor = connection.cursor() - -try: - s_query = """SELECT * FROM public.parse""" - cursor.execute(s_query) -except psycopg2.errors.UndefinedTable: #рассматриваем случай, когда таблицы нет - connection.rollback() #возвращаемся "на действие назад" - import FHWDB #создаём и заполняем таблицу, если её не существовало ранее - connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') - cursor = connection.cursor() - s_query = '''SELECT * FROM public.parse''' - cursor.execute(s_query) -finally: - arr = list(cursor.fetchall()) - -bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw') - -@bot.message_handler(commands=["start"]) -def start(m, res=False): - markup = types.ReplyKeyboardMarkup(resize_keyboard=True) - item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста") - item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста") - item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста") - item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных") - markup.add(item1) - markup.add(item2) - markup.add(item3) - markup.add(item4) - bot.send_message(m.chat.id, - '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.', - reply_markup=markup) - -@bot.message_handler(content_types=["text"]) -def handle_text(message): - if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"): - i = random.choice(arr) - a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n' - bot.send_message(message.chat.id, a1) - elif (message.text.strip() == "Хочу картинку любых цветов, пожалуйста"): - i = random.choice(arr) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - elif (message.text.strip() == "Хочу информацию о предложении дня, пожалуйста"): - j = random.randint(1, 61) - i = list(select(j)) - a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n' - bot.send_message(message.chat.id, "Предложение дня:\n") - bot.send_message(message.chat.id, a1) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - else: - bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ") - -bot.polling(none_stop=True, interval=0) - -cursor.close() -connection.close() \ No newline at end of file From a6e53afcea24bdd120f4fbbff58e1d300a2a4781 Mon Sep 17 00:00:00 2001 From: VladEpifanov Date: Sun, 23 Apr 2023 14:32:50 +0300 Subject: [PATCH 12/43] =?UTF-8?q?=D0=9A=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=91=D0=94=20+=20=D0=B7=D0=B0=D0=B4=D0=B5=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B8=D0=B7=20wwfuncs.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...py => tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Задания/task1/Epifanov/{tgBot(try-exc-finally+usage of func-s.py => tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py} (100%) diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py similarity index 100% rename from Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py rename to Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py From cb6699217d6b8a2bbcd7960ac776580355109cec Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:39:06 +0300 Subject: [PATCH 13/43] Update tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py --- .../tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py index 47b402d..5aa490e 100644 --- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py +++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py @@ -26,7 +26,7 @@ bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw') @bot.message_handler(commands=["start"]) def start(m, res=False): markup = types.ReplyKeyboardMarkup(resize_keyboard=True) - item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста") + item1 = types.KeyboardButton("Хочу информацию о любых цветах, пожалуйста") item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста") item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста") item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных") @@ -60,4 +60,4 @@ def handle_text(message): bot.polling(none_stop=True, interval=0) cursor.close() -connection.close() \ No newline at end of file +connection.close() From 443831358966776c2ee61d199675a71de577f12e Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:54:28 +0300 Subject: [PATCH 14/43] Update tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py --- .../tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py index 5aa490e..4b804da 100644 --- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py +++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py @@ -40,7 +40,7 @@ def start(m, res=False): @bot.message_handler(content_types=["text"]) def handle_text(message): - if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"): + if (message.text.strip() == "Хочу информацию о любых цветах, пожалуйста"): i = random.choice(arr) a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n' bot.send_message(message.chat.id, a1) From 842f08f77337084081675e4d79c065e1dbe126ae Mon Sep 17 00:00:00 2001 From: Harutyun Date: Wed, 26 Apr 2023 14:09:41 +0300 Subject: [PATCH 15/43] attempt to create telegramBot --- Задания/task1/Garanyan/{main.py => parser.py} | 0 Задания/task1/Garanyan/problems.py | 30 +++++++++++++++++++ Задания/task1/Garanyan/tgbot.py | 16 +++++----- 3 files changed, 38 insertions(+), 8 deletions(-) rename Задания/task1/Garanyan/{main.py => parser.py} (100%) create mode 100644 Задания/task1/Garanyan/problems.py diff --git a/Задания/task1/Garanyan/main.py b/Задания/task1/Garanyan/parser.py similarity index 100% rename from Задания/task1/Garanyan/main.py rename to Задания/task1/Garanyan/parser.py diff --git a/Задания/task1/Garanyan/problems.py b/Задания/task1/Garanyan/problems.py new file mode 100644 index 0000000..018fd04 --- /dev/null +++ b/Задания/task1/Garanyan/problems.py @@ -0,0 +1,30 @@ +import psycopg2 +import wget + +from Задания.task1.Garanyan import parser + +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', + password='Q1w2e3r4') +cursor = connection.cursor() +create_q = '''CREATE TABLE Food + (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))''' + +try: + cursor.execute(create_q) + connection.commit() +except psycopg2.errors.DuplicateTable: + print("s") + +for j in range(15): + url = parser.Image[j].find('img').attrs['src'] + tempf = f"C:\\Users\\Harutyun\\Desktop\\prog\\food{j}.jpg" + wget.download(url, tempf) + try: + insert_query = f'''INSERT into public.Food(Name, Price, src) values ('{parser.Name[j].text}', '{parser.Price[j].text}', '{tempf}') ''' + cursor.execute(insert_query) + connection.commit() + except: + connection.rollback() + +cursor.close() +connection.close() \ No newline at end of file diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py index 2b47151..4bc1be5 100644 --- a/Задания/task1/Garanyan/tgbot.py +++ b/Задания/task1/Garanyan/tgbot.py @@ -2,7 +2,7 @@ import telebot import psycopg2 from telebot import types import random -#hello + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() @@ -11,8 +11,7 @@ try: cursor.execute(sel_query) except psycopg2.errors.UndefinedTable: connection.rollback() - import tableCreator - + import problems sel_query = """SELECT * FROM public.food""" cursor.execute(sel_query) @@ -25,14 +24,14 @@ bot = telebot.TeleBot('841097550:AAFc5MoFRivTEfv-gOSJctqH53NfYMTKpCc') def start(m, res=False): markup = types.ReplyKeyboardMarkup(resize_keyboard=True) item1 = types.KeyboardButton("Хот-доги и соусы!") - item2 = types.KeyboardButton("Повтори!") + item2 = types.KeyboardButton("Случайная фотография нашего товара!") markup.add(item1) markup.add(item2) bot.send_message(m.chat.id, - '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n "Повтори!" - для повторения сообщений.', + '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n' + ' "Случайная фотография нашего товара!" - для вывода фотографий', reply_markup=markup) - @bot.message_handler(content_types=["text"]) def handle_text(message): if (message.text.strip() == 'Хот-доги и соусы!'): @@ -40,8 +39,9 @@ def handle_text(message): ans = f'Название: {i[1]}\nЦена: {i[2]}\n' bot.send_message(message.chat.id, ans) bot.send_photo(message.chat.id, open(i[3], 'rb')) - elif (message.text.strip() == 'Повтори!'): - bot.send_message(message.chat.id, 'Ввод: ' + message.text) + elif (message.text.strip() == 'Случайная фотография нашего товара!'): + i = random.choice(array) + bot.send_photo(message.chat.id, open(i[3], 'rb')) bot.polling(none_stop=True, interval=0) \ No newline at end of file From 5eb266a15e43c7d68d567aae410fdbddc8ea6fec Mon Sep 17 00:00:00 2001 From: pErfEcto2 Date: Wed, 26 Apr 2023 14:16:40 +0300 Subject: [PATCH 16/43] car class added --- Задания/task1/Yaroshevskiy/oop.py | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Задания/task1/Yaroshevskiy/oop.py diff --git a/Задания/task1/Yaroshevskiy/oop.py b/Задания/task1/Yaroshevskiy/oop.py new file mode 100644 index 0000000..aac44f0 --- /dev/null +++ b/Задания/task1/Yaroshevskiy/oop.py @@ -0,0 +1,37 @@ +from time import time, sleep +from random import random + + +class Car: + def __init__(self, model: str = "Aston Martin", + color: str = "Black", + volume: int = 30, + consp: int = 1): + self.model = model + self.color = color + self.all_volume = volume + self.volume = volume + self.consumption = consp + + def start(self) -> int: + self.start_time = int(time()) + return self.volume // self.consumption + + def stop(self) -> int: + self.volume -= self.consumption * (int(time()) - self.start_time) + return self.volume + + def show_info(self) -> None: + print( + f"model: {self.model}; color: {self.color}; all volume: {self.all_volume}; volume left: {self.volume}") + + +car = Car(volume=10) + +time_sleep = int(car.start() * random()) +print(f"time for working: {time_sleep} seconds") + +sleep(time_sleep) + +car.stop() +car.show_info() From b0738b27ec7810a7c108777cc65d1d2af608b232 Mon Sep 17 00:00:00 2001 From: inweems Date: Wed, 26 Apr 2023 22:00:09 +0300 Subject: [PATCH 17/43] botparsing --- Задания/task1/Prokhorova/botpars.py | 37 +++++++++++++++++++++++++++++ Задания/task1/Prokhorova/dz.py | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Задания/task1/Prokhorova/botpars.py diff --git a/Задания/task1/Prokhorova/botpars.py b/Задания/task1/Prokhorova/botpars.py new file mode 100644 index 0000000..2063830 --- /dev/null +++ b/Задания/task1/Prokhorova/botpars.py @@ -0,0 +1,37 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') + +cursor = connection.cursor() + +BD = """SELECT * FROM public.food""" +cursor.execute(BD) +array = list(cursor.fetchall()) + +bot = telebot.TeleBot('5696445699:AAEPKQgUAs39DTLr_iyQvlaFAsJNFK8DMnc') +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Рандомный товар") + item2 = types.KeyboardButton("Повтор !") + markup.add(item1) + markup.add(item2) + bot.send_message(m.chat.id, + '"Рандомный товар" - для получения карточки товара\n "Повтори !" - для повторения сообщений.', + reply_markup=markup) + + +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if (message.text.strip() == 'Рандомный товар'): + i = random.choice(array) + ans = f'Название: {i[1]}\nЦена: {i[2]}\nГрамм: {i[3]}\nРэйтинг: {i[4]}\n' + bot.send_message(message.chat.id, ans) + elif (message.text.strip() == 'Повтори !'): + bot.send_message(message.chat.id, 'Ввод: ' + message.text) + + +bot.polling(none_stop=True, interval=0) \ No newline at end of file diff --git a/Задания/task1/Prokhorova/dz.py b/Задания/task1/Prokhorova/dz.py index 2dfcb87..1a47e12 100644 --- a/Задания/task1/Prokhorova/dz.py +++ b/Задания/task1/Prokhorova/dz.py @@ -1,8 +1,9 @@ -import psycopg2 + import psycopg2 import wget from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.chrome.service import Service + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() From e4f0ef9af29efd35925ee52078cb7a65a77b34f3 Mon Sep 17 00:00:00 2001 From: Harutyun Date: Wed, 26 Apr 2023 23:03:28 +0300 Subject: [PATCH 18/43] maybe last version --- Задания/task1/Garanyan/parser.py | 7 +++---- Задания/task1/Garanyan/problems.py | 10 ++++------ Задания/task1/Garanyan/tgbot.py | 27 ++++++++++++--------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Задания/task1/Garanyan/parser.py b/Задания/task1/Garanyan/parser.py index 8e6da15..e4432ec 100644 --- a/Задания/task1/Garanyan/parser.py +++ b/Задания/task1/Garanyan/parser.py @@ -14,15 +14,14 @@ Image = soup.find_all(attrs={"class": "holder-img"}) connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() -create_q = '''CREATE TABLE Food - (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))''' +create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))''' cursor.execute(create_q) connection.commit() #https://smartomato.ams3.cdn.digitaloceanspaces.com/uploads/media/photo/769221/dish_large__1.jpg -for j in range(15): +for j in range(19): url = Image[j].find('img').attrs['src'] - tempf = f"C:\\Users\\Harutyun\\Desktop\\prog\\food{j}.jpg" + tempf = f"img\\food{j}.jpg" wget.download(url, tempf) insert_query = f'''INSERT into public.Food(Name, Price, src) values ('{Name[j].text}', '{Price[j].text}', '{tempf}') ''' cursor.execute(insert_query) diff --git a/Задания/task1/Garanyan/problems.py b/Задания/task1/Garanyan/problems.py index 018fd04..9cfb872 100644 --- a/Задания/task1/Garanyan/problems.py +++ b/Задания/task1/Garanyan/problems.py @@ -3,21 +3,19 @@ import wget from Задания.task1.Garanyan import parser -connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', - password='Q1w2e3r4') +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() -create_q = '''CREATE TABLE Food - (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))''' +create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))''' try: cursor.execute(create_q) connection.commit() except psycopg2.errors.DuplicateTable: - print("s") + print("duplicate error") for j in range(15): url = parser.Image[j].find('img').attrs['src'] - tempf = f"C:\\Users\\Harutyun\\Desktop\\prog\\food{j}.jpg" + tempf = f"img\\food{j}.jpg" wget.download(url, tempf) try: insert_query = f'''INSERT into public.Food(Name, Price, src) values ('{parser.Name[j].text}', '{parser.Price[j].text}', '{tempf}') ''' diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py index 4bc1be5..f02959a 100644 --- a/Задания/task1/Garanyan/tgbot.py +++ b/Задания/task1/Garanyan/tgbot.py @@ -3,8 +3,7 @@ import psycopg2 from telebot import types import random -connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', - password='Q1w2e3r4') +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() try: sel_query = """SELECT * FROM public.food""" @@ -16,32 +15,30 @@ except psycopg2.errors.UndefinedTable: cursor.execute(sel_query) array = list(cursor.fetchall()) - bot = telebot.TeleBot('841097550:AAFc5MoFRivTEfv-gOSJctqH53NfYMTKpCc') - @bot.message_handler(commands=["start"]) def start(m, res=False): markup = types.ReplyKeyboardMarkup(resize_keyboard=True) - item1 = types.KeyboardButton("Хот-доги и соусы!") - item2 = types.KeyboardButton("Случайная фотография нашего товара!") + item1 = types.KeyboardButton("Хот-доги и не только!") + item2 = types.KeyboardButton("Цена товара") markup.add(item1) markup.add(item2) bot.send_message(m.chat.id, - '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n' - ' "Случайная фотография нашего товара!" - для вывода фотографий', - reply_markup=markup) + '"Хот-доги и не только!" - для получения случайного товара из нашей хотдожной\n' + ' "Цена товара" - для вывода цены', reply_markup=markup) +i = random.choice(array) @bot.message_handler(content_types=["text"]) def handle_text(message): - if (message.text.strip() == 'Хот-доги и соусы!'): + global i + if (message.text.strip() == 'Хот-доги и не только!'): i = random.choice(array) - ans = f'Название: {i[1]}\nЦена: {i[2]}\n' + ans = f'Название: {i[1]}\n' bot.send_message(message.chat.id, ans) bot.send_photo(message.chat.id, open(i[3], 'rb')) - elif (message.text.strip() == 'Случайная фотография нашего товара!'): - i = random.choice(array) - bot.send_photo(message.chat.id, open(i[3], 'rb')) - + elif (message.text.strip() == 'Цена товара'): + ans = f'Цена: {i[2]}\n' + bot.send_message(message.chat.id, ans) bot.polling(none_stop=True, interval=0) \ No newline at end of file From a65c741e40c20b6435fe0746b3c8ac648f82bc5a Mon Sep 17 00:00:00 2001 From: TatianaFilcheva <124861990+TatianaFilcheva@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:52:20 +0300 Subject: [PATCH 19/43] Add files via upload --- Задания/task1/Filcheva/Subot.py | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Задания/task1/Filcheva/Subot.py diff --git a/Задания/task1/Filcheva/Subot.py b/Задания/task1/Filcheva/Subot.py new file mode 100644 index 0000000..9149111 --- /dev/null +++ b/Задания/task1/Filcheva/Subot.py @@ -0,0 +1,70 @@ +import telebot +import psycopg2 +from telebot import types +# Создаем экземпляр бота +bot = telebot.TeleBot('5898574743:AAF2y_y3U2IfWwQVJ_lF6mmiDPlx1YgU9-Q') +# Функция, обрабатывающая команду /start + +def reply_to_user(message, bot): + query = f"insert into Distilleries(name, place, contacts) values ('{message.text.strip()}', " + bot.send_message(message.chat.id, "Введите адрес винокурни") + bot.register_next_step_handler(message, f2, bot, query) + +def f2(message, bot, query): + query += f"'{message.text.strip()}', " + bot.send_message(message.chat.id, "Введите контакты") + bot.register_next_step_handler(message, f3, bot, query) + +def f3(message, bot, query): + query += f"'{message.text.strip()}')" + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5') + cursor = connection.cursor() + cursor.execute(query) + connection.commit() + cursor.close() + connection.close() + bot.send_message(message.chat.id, "Done") + +@bot.message_handler(commands=["start"]) +def start_messanger(messanger): + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5') + cursor = connection.cursor() + cursor.execute("select id, name from Distilleries") + first_step = [] + for id, name in cursor.fetchall(): + f_s = str(id) + '. ' + name + first_step.append(f_s) + my_str = '\n'.join(first_step) + bot.send_message(messanger.chat.id, 'Я на связи. Выберите интересующую вас Винокурню, введите ее номер\n' + my_str.strip()) + cursor.close() + connection.close() + + +@bot.message_handler(content_types=["text"]) +def output(put): + n = put.text.strip() + if n.isalpha(): + if n == 'Да': + bot.send_message(put.chat.id, 'Введите название винокурни') + bot.register_next_step_handler(put, reply_to_user, bot) + elif n == 'Нет': + bot.send_message(put.chat.id, 'Хорошего дня') + + else: + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5') + cursor = connection.cursor() + cursor.execute(f"select place, contacts, imagelink from Distilleries where id = {n}") + for place, contacts, imagelink in cursor.fetchall(): + answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink + bot.send_message(put.chat.id, answer) + cursor.close() + connection.close() + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton('Да') + item2 = types.KeyboardButton('Нет') + markup.add(item1) + markup.add(item2) + bot.send_message(put.chat.id, 'Хотите ли добавить еще одну винокурнею Крыма?', reply_markup=markup ) + + +bot.polling(none_stop=True, interval=0) From ce4490974de95890dd078925c93fddff13ebc988 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:27:48 +0300 Subject: [PATCH 20/43] Add files via upload parsing DATABASE --- Задания/task1/Gasanova/parsing.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Задания/task1/Gasanova/parsing.py diff --git a/Задания/task1/Gasanova/parsing.py b/Задания/task1/Gasanova/parsing.py new file mode 100644 index 0000000..ffecd72 --- /dev/null +++ b/Задания/task1/Gasanova/parsing.py @@ -0,0 +1,30 @@ +# парсер к полусему 8 неделя +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +from wget import download +import psycopg2 as psyc + +# s = Service("chromedriver") на Ubuntu можно не указывать путь до драйвера если что :) +URL = "https://proskateshop.ru/skejtbordy/?utm_source=yandex&utm_medium=cpc&utm_campaign=cn%7Cskeyty_gz-1%7Ccid%7C51517250%7Csearch&utm_content=gid%7C4180310153%7Caid%7C8980588780%7C20506942844_20506942844%7Cmain&utm_term=%D0%9F%D0%B5%D0%BD%D0%BD%D0%B8%20%D0%B1%D0%BE%D1%80%D0%B4%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C&etext=2202.N39xvihj0F0Od_d4etv_6nh36sdlRP-T26wHLuCJfjo_JZtVI5O7HY5f8FOJnzuLZXB6eWZoZnp2dG1laHBlcA.aceac50a24e4832d82874cd59ca1f9a315d9b351&_openstat=ZGlyZWN0LnlhbmRleC5ydTs1MTUxNzI1MDs4OTgwNTg4NzgwO3lhbmRleC5ydTpndWFyYW50ZWU&yclid=1445113833197462400" +brow = webdriver.Chrome() +brow.get(URL) + +html = brow.page_source + +soup = BeautifulSoup(html, "lxml") + +penny = soup.find_all(attrs={"class": "product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-6"}) + +with psyc.connect(host = "localhost", dbname="work", user="dialuna", password = "Timka07") as conn: + with conn.cursor() as cursor: + for i, product in enumerate(penny[1:]): + image_link = product.find("img").attrs.get("src") + image_name = product.find("img").attrs.get("alt") + price = product.find("p", attrs={"class": "price"}).text.strip() + download( product.find("img").attrs.get("src"), f"images/{i}.jpg") + + cursor.execute(f"""insert into bot(link, name, price, file) + values ('{image_link}', '{image_name}', '{price}', 'images/{i}.jpg')""") + + conn.commit() From 53ee82311c827e3d7aa6631dfe8fa4ff9db51219 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:28:09 +0300 Subject: [PATCH 21/43] Delete penny.py --- Задания/task1/Gasanova/penny.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 Задания/task1/Gasanova/penny.py diff --git a/Задания/task1/Gasanova/penny.py b/Задания/task1/Gasanova/penny.py deleted file mode 100644 index 686e539..0000000 --- a/Задания/task1/Gasanova/penny.py +++ /dev/null @@ -1,29 +0,0 @@ -# парсер к полусему 8 неделя -from bs4 import BeautifulSoup -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -from wget import download -import psycopg2 as psyc - -# s = Service("chromedriver") на Ubuntu можно не указывать путь до драйвера :) -URL = "https://proskateshop.ru/skejtbordy/?utm_source=yandex&utm_medium=cpc&utm_campaign=cn%7Cskeyty_gz-1%7Ccid%7C51517250%7Csearch&utm_content=gid%7C4180310153%7Caid%7C8980588780%7C20506942844_20506942844%7Cmain&utm_term=%D0%9F%D0%B5%D0%BD%D0%BD%D0%B8%20%D0%B1%D0%BE%D1%80%D0%B4%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C&etext=2202.N39xvihj0F0Od_d4etv_6nh36sdlRP-T26wHLuCJfjo_JZtVI5O7HY5f8FOJnzuLZXB6eWZoZnp2dG1laHBlcA.aceac50a24e4832d82874cd59ca1f9a315d9b351&_openstat=ZGlyZWN0LnlhbmRleC5ydTs1MTUxNzI1MDs4OTgwNTg4NzgwO3lhbmRleC5ydTpndWFyYW50ZWU&yclid=1445113833197462400" -brow = webdriver.Chrome() -brow.get(URL) - -html = brow.page_source - -soup = BeautifulSoup(html, "lxml") - -penny = soup.find_all(attrs={"class": "product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-6"}) - -with psyc.connect(dbname="db_for_parse", user="dialuna") as conn: - with conn.cursor() as cursor: - for i, product in enumerate(penny[1:]): - image_link = product.find("img").attrs.get("src") - image_name = product.find("img").attrs.get("alt") - price = product.find("p", attrs={"class": "price"}).text.strip() - - cursor.execute(f"""insert into test(link, name, price, file) - values ('{image_link}', '{image_name}', '{price}', 'images/{i}.jpg')""") - - conn.commit() From d3f8c95fd87ea5f0e7676ed19fe8e5ad9e5f4fd3 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:31:31 +0300 Subject: [PATCH 22/43] Add files via upload Telegram Bot --- Задания/task1/Gasanova/bot_database.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py new file mode 100644 index 0000000..572268a --- /dev/null +++ b/Задания/task1/Gasanova/bot_database.py @@ -0,0 +1,62 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') +cursor = connection.cursor() +try: + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import problems + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) + +array = list(cursor.fetchall()) + + +bot = telebot.TeleBot('secret') + +@bot.message_handler(commands=['start']) +def start(message): + sti = open('st.webp', 'rb') + bot.send_sticker(message.chat.id, sti) + + bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\n Я твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) + +#@bot.message_handler(content_types=['text']) +#def get_text_messages(message): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок + btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") + btn2 = types.KeyboardButton("Предложение дня") + btn3 = types.KeyboardButton("Выбор редакции нашей компании") + markup.add(btn1, btn2, btn3) + bot.send_message(message.chat.id, + 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', + reply_markup=markup) + + +@bot.message_handler(content_types=['text']) +def handle_text(message): + if (message.text.strip() == "Лучший скейтборд этого сезона"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + elif (message.text.strip() == "Предложение дня"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + elif (message.text.strip() == "Выбор редакции нашей компании"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + else: + bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") + + +bot.polling(none_stop=True, interval=0) From 1f773148bd8c7665624f29f0675ff7b8952016cf Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:32:38 +0300 Subject: [PATCH 23/43] Update bot_database.py --- Задания/task1/Gasanova/bot_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py index 572268a..cb5b4aa 100644 --- a/Задания/task1/Gasanova/bot_database.py +++ b/Задания/task1/Gasanova/bot_database.py @@ -3,7 +3,7 @@ import psycopg2 from telebot import types import random -connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') +connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :) cursor = connection.cursor() try: sel_query = """SELECT * FROM bot""" From acd613b2295282f599f10c32c5f4c2144b4b7984 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:33:12 +0300 Subject: [PATCH 24/43] Update bot_database.py --- Задания/task1/Gasanova/bot_database.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py index cb5b4aa..25fcaba 100644 --- a/Задания/task1/Gasanova/bot_database.py +++ b/Задания/task1/Gasanova/bot_database.py @@ -13,9 +13,8 @@ except psycopg2.errors.UndefinedTable: import problems sel_query = """SELECT * FROM bot""" cursor.execute(sel_query) - -array = list(cursor.fetchall()) +array = list(cursor.fetchall()) bot = telebot.TeleBot('secret') @@ -36,8 +35,7 @@ def start(message): bot.send_message(message.chat.id, 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', reply_markup=markup) - - + @bot.message_handler(content_types=['text']) def handle_text(message): if (message.text.strip() == "Лучший скейтборд этого сезона"): From e3a0c3429b2ec570256e37f4f132eae4211472f2 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:33:44 +0300 Subject: [PATCH 25/43] Update bot_database.py --- Задания/task1/Gasanova/bot_database.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py index 25fcaba..eca2f21 100644 --- a/Задания/task1/Gasanova/bot_database.py +++ b/Задания/task1/Gasanova/bot_database.py @@ -25,8 +25,6 @@ def start(message): bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\n Я твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) -#@bot.message_handler(content_types=['text']) -#def get_text_messages(message): markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") btn2 = types.KeyboardButton("Предложение дня") From b07ba7438603a44b2b63acea7c710028a3b93078 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:07:01 +0300 Subject: [PATCH 26/43] Delete bot_database.py --- Задания/task1/Gasanova/bot_database.py | 58 -------------------------- 1 file changed, 58 deletions(-) delete mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py deleted file mode 100644 index eca2f21..0000000 --- a/Задания/task1/Gasanova/bot_database.py +++ /dev/null @@ -1,58 +0,0 @@ -import telebot -import psycopg2 -from telebot import types -import random - -connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :) -cursor = connection.cursor() -try: - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) -except psycopg2.errors.UndefinedTable: - connection.rollback() - import problems - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) - -array = list(cursor.fetchall()) - -bot = telebot.TeleBot('secret') - -@bot.message_handler(commands=['start']) -def start(message): - sti = open('st.webp', 'rb') - bot.send_sticker(message.chat.id, sti) - - bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\n Я твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) - - markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок - btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") - btn2 = types.KeyboardButton("Предложение дня") - btn3 = types.KeyboardButton("Выбор редакции нашей компании") - markup.add(btn1, btn2, btn3) - bot.send_message(message.chat.id, - 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', - reply_markup=markup) - -@bot.message_handler(content_types=['text']) -def handle_text(message): - if (message.text.strip() == "Лучший скейтборд этого сезона"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - elif (message.text.strip() == "Предложение дня"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - elif (message.text.strip() == "Выбор редакции нашей компании"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - else: - bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") - - -bot.polling(none_stop=True, interval=0) From dcc37d31827e058bc4d4a81131d0e649a78f02cb Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:07:36 +0300 Subject: [PATCH 27/43] DATABASE AND TELEGRAM BOT !!! DATABASE AND TELEGRAM BOT !!! --- Задания/task1/Gasanova/bot_database.py | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py new file mode 100644 index 0000000..632eae1 --- /dev/null +++ b/Задания/task1/Gasanova/bot_database.py @@ -0,0 +1,71 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :D +cursor = connection.cursor() +try: + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import problems + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) + +array = list(cursor.fetchall()) + + +bot = telebot.TeleBot('secret') + +@bot.message_handler(commands=['start']) +def start(message): + sti = open('st.webp', 'rb') + bot.send_sticker(message.chat.id, sti) + + bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\nЯ твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) + +#@bot.message_handler(content_types=['text']) +#def get_text_messages(message): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок + btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") + btn2 = types.KeyboardButton("Предложение дня") + btn3 = types.KeyboardButton("Выбор редакции нашей компании") + markup.add(btn1, btn2, btn3) + bot.send_message(message.chat.id, + 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', + reply_markup=markup) + + +@bot.message_handler(content_types=['text']) +def handle_text(message): + if (message.text.strip() == "Лучший скейтборд этого сезона"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + elif (message.text.strip() == "Предложение дня"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_sticker(message.chat.id, cat) + elif (message.text.strip() == "Выбор редакции нашей компании"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + else: + bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") + + + + + +bot.polling(none_stop=True, interval=0) From e36751190150f8e2bd3496cc56f2e2953e3eb9c4 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:08:29 +0300 Subject: [PATCH 28/43] Delete bot_database.py --- Задания/task1/Gasanova/bot_database.py | 71 -------------------------- 1 file changed, 71 deletions(-) delete mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py deleted file mode 100644 index 632eae1..0000000 --- a/Задания/task1/Gasanova/bot_database.py +++ /dev/null @@ -1,71 +0,0 @@ -import telebot -import psycopg2 -from telebot import types -import random - -connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :D -cursor = connection.cursor() -try: - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) -except psycopg2.errors.UndefinedTable: - connection.rollback() - import problems - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) - -array = list(cursor.fetchall()) - - -bot = telebot.TeleBot('secret') - -@bot.message_handler(commands=['start']) -def start(message): - sti = open('st.webp', 'rb') - bot.send_sticker(message.chat.id, sti) - - bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\nЯ твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) - -#@bot.message_handler(content_types=['text']) -#def get_text_messages(message): - markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок - btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") - btn2 = types.KeyboardButton("Предложение дня") - btn3 = types.KeyboardButton("Выбор редакции нашей компании") - markup.add(btn1, btn2, btn3) - bot.send_message(message.chat.id, - 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', - reply_markup=markup) - - -@bot.message_handler(content_types=['text']) -def handle_text(message): - if (message.text.strip() == "Лучший скейтборд этого сезона"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_video(message.chat.id, cat) - elif (message.text.strip() == "Предложение дня"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_sticker(message.chat.id, cat) - elif (message.text.strip() == "Выбор редакции нашей компании"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_video(message.chat.id, cat) - else: - bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") - - - - - -bot.polling(none_stop=True, interval=0) From 0920877351a3fee1d74ce3307a1f0527ead94298 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:09:39 +0300 Subject: [PATCH 29/43] TELEGRAM_BOT/DATABASE !!! --- Задания/task1/Gasanova/bot_database.py | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py new file mode 100644 index 0000000..00e27dc --- /dev/null +++ b/Задания/task1/Gasanova/bot_database.py @@ -0,0 +1,67 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :D +cursor = connection.cursor() + +try: + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import problems + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) + +array = list(cursor.fetchall()) + + +bot = telebot.TeleBot('secret') + +@bot.message_handler(commands=['start']) +def start(message): + sti = open('st.webp', 'rb') + bot.send_sticker(message.chat.id, sti) + bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\nЯ твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) + + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок + btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") + btn2 = types.KeyboardButton("Предложение дня") + btn3 = types.KeyboardButton("Выбор редакции нашей компании") + markup.add(btn1, btn2, btn3) + bot.send_message(message.chat.id, + 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', + reply_markup=markup) + + +@bot.message_handler(content_types=['text']) +def handle_text(message): + if (message.text.strip() == "Лучший скейтборд этого сезона"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + elif (message.text.strip() == "Предложение дня"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_sticker(message.chat.id, cat) + elif (message.text.strip() == "Выбор редакции нашей компании"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + else: + bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") + + + +bot.polling(none_stop=True, interval=0) From 6aca2deea716597f25b62ee2ca223321693119ba Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:25:33 +0300 Subject: [PATCH 30/43] Update bot_database.py --- Задания/task1/Gasanova/bot_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py index 00e27dc..11dd716 100644 --- a/Задания/task1/Gasanova/bot_database.py +++ b/Задания/task1/Gasanova/bot_database.py @@ -51,7 +51,7 @@ def handle_text(message): bot.send_message(message.chat.id, ans) bot.send_photo(message.chat.id, open(i[4], 'rb')) cat = open('kotik.webm', 'rb') - bot.send_sticker(message.chat.id, cat) + bot.send_video(message.chat.id, cat) elif (message.text.strip() == "Выбор редакции нашей компании"): i = random.choice(array) ans = f'Название: {i[2]}\nЦена: {i[3]}\n' From 4db76bd795e1f3a38088d423d1e8bfbdd575c11c Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:25:57 +0300 Subject: [PATCH 31/43] Delete bot_database.py --- Задания/task1/Gasanova/bot_database.py | 67 -------------------------- 1 file changed, 67 deletions(-) delete mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py deleted file mode 100644 index 11dd716..0000000 --- a/Задания/task1/Gasanova/bot_database.py +++ /dev/null @@ -1,67 +0,0 @@ -import telebot -import psycopg2 -from telebot import types -import random - -connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :D -cursor = connection.cursor() - -try: - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) -except psycopg2.errors.UndefinedTable: - connection.rollback() - import problems - sel_query = """SELECT * FROM bot""" - cursor.execute(sel_query) - -array = list(cursor.fetchall()) - - -bot = telebot.TeleBot('secret') - -@bot.message_handler(commands=['start']) -def start(message): - sti = open('st.webp', 'rb') - bot.send_sticker(message.chat.id, sti) - bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\nЯ твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) - - markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок - btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") - btn2 = types.KeyboardButton("Предложение дня") - btn3 = types.KeyboardButton("Выбор редакции нашей компании") - markup.add(btn1, btn2, btn3) - bot.send_message(message.chat.id, - 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', - reply_markup=markup) - - -@bot.message_handler(content_types=['text']) -def handle_text(message): - if (message.text.strip() == "Лучший скейтборд этого сезона"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_video(message.chat.id, cat) - elif (message.text.strip() == "Предложение дня"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_video(message.chat.id, cat) - elif (message.text.strip() == "Выбор редакции нашей компании"): - i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) - bot.send_photo(message.chat.id, open(i[4], 'rb')) - cat = open('kotik.webm', 'rb') - bot.send_video(message.chat.id, cat) - else: - bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") - - - -bot.polling(none_stop=True, interval=0) From 3abdc8993bd294060c2ee022bdf89e5399770e94 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:26:40 +0300 Subject: [PATCH 32/43] TELEGRAM_BOT / DATABASE !!! --- Задания/task1/Gasanova/bot_database.py | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Задания/task1/Gasanova/bot_database.py diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py new file mode 100644 index 0000000..11dd716 --- /dev/null +++ b/Задания/task1/Gasanova/bot_database.py @@ -0,0 +1,67 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(host='localhost', dbname='work', user='dialuna', password='Timka07') # да-да :D +cursor = connection.cursor() + +try: + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import problems + sel_query = """SELECT * FROM bot""" + cursor.execute(sel_query) + +array = list(cursor.fetchall()) + + +bot = telebot.TeleBot('secret') + +@bot.message_handler(commands=['start']) +def start(message): + sti = open('st.webp', 'rb') + bot.send_sticker(message.chat.id, sti) + bot.send_message(message.chat.id, "ЙОУ, {0.first_name}!\nЯ твой помощник в мире скейтбординга😎".format(message.from_user, bot.get_me())) + + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) #создание кнопок + btn1 = types.KeyboardButton("Лучший скейтборд этого сезона") + btn2 = types.KeyboardButton("Предложение дня") + btn3 = types.KeyboardButton("Выбор редакции нашей компании") + markup.add(btn1, btn2, btn3) + bot.send_message(message.chat.id, + 'Лучший скейтборд этого сезона - это именно то, что тебе нужно, если хочешь быть самым крутым.\nПредложение дня - то, что актуально на сегодняшний день.\nВыбор редакции - просто доверься выбору наших сотрудников и тебе понравится :)\n', + reply_markup=markup) + + +@bot.message_handler(content_types=['text']) +def handle_text(message): + if (message.text.strip() == "Лучший скейтборд этого сезона"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + elif (message.text.strip() == "Предложение дня"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + elif (message.text.strip() == "Выбор редакции нашей компании"): + i = random.choice(array) + ans = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[4], 'rb')) + cat = open('kotik.webm', 'rb') + bot.send_video(message.chat.id, cat) + else: + bot.send_message(message.chat.id, "Наш бот поможет подобрать вам или близким скейтборд мечты. Скорее пробуйте! ") + + + +bot.polling(none_stop=True, interval=0) From e5609ed074dd75bcf087d9fbb825539dc62e4e29 Mon Sep 17 00:00:00 2001 From: Lady Di <93448337+dialuna@users.noreply.github.com> Date: Sun, 30 Apr 2023 10:05:32 +0300 Subject: [PATCH 33/43] bot_database.py --- Задания/task1/Gasanova/bot_database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Задания/task1/Gasanova/bot_database.py b/Задания/task1/Gasanova/bot_database.py index 11dd716..1c3d867 100644 --- a/Задания/task1/Gasanova/bot_database.py +++ b/Задания/task1/Gasanova/bot_database.py @@ -40,22 +40,22 @@ def start(message): def handle_text(message): if (message.text.strip() == "Лучший скейтборд этого сезона"): i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) + inf = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, inf) bot.send_photo(message.chat.id, open(i[4], 'rb')) cat = open('kotik.webm', 'rb') bot.send_video(message.chat.id, cat) elif (message.text.strip() == "Предложение дня"): i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) + inf = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, inf) bot.send_photo(message.chat.id, open(i[4], 'rb')) cat = open('kotik.webm', 'rb') bot.send_video(message.chat.id, cat) elif (message.text.strip() == "Выбор редакции нашей компании"): i = random.choice(array) - ans = f'Название: {i[2]}\nЦена: {i[3]}\n' - bot.send_message(message.chat.id, ans) + inf = f'Название: {i[2]}\nЦена: {i[3]}\n' + bot.send_message(message.chat.id, inf) bot.send_photo(message.chat.id, open(i[4], 'rb')) cat = open('kotik.webm', 'rb') bot.send_video(message.chat.id, cat) From c992f227492df872126ae5b376a9e611d4e40d9c Mon Sep 17 00:00:00 2001 From: Dronminator Date: Mon, 1 May 2023 20:06:30 +0300 Subject: [PATCH 34/43] =?UTF-8?q?=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=20=D0=91=D0=BE=D1=82=20=D0=B8=20=D0=A4=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D1=81=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Lahin/postgres.py | 17 +++++---- Задания/task1/Lahin/select_and_edit'.py | 27 ++++++++++++++ Задания/task1/Lahin/telegrambot.py | 47 +++++++++++++++++-------- 3 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 Задания/task1/Lahin/select_and_edit'.py diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py index fe8a029..c0620eb 100644 --- a/Задания/task1/Lahin/postgres.py +++ b/Задания/task1/Lahin/postgres.py @@ -49,12 +49,15 @@ for i in range(len(productst)): u.append(features[10*i+j].text) wget.download(url, filename) t = pricest[i].text.replace("\xa0", " ") - insert = f"""INSERT INTO public.laptops( - Product, Price, Diagonal, Resolution, CPU, RAM, Graphics_Controller, Volume, src) - VALUES - ('{productst[i].text.strip()}', '{t.strip()}', '{u[0][:u[0].find("/")]}', '{u[0][u[0].find("/")+1:]}', - '{u[2]}', '{u[4]+" "+u[5]}', '{u[6]}', '{u[8]}', '{filename}');""" - cursor.execute(insert) - connection.commit() + try: + insert = f"""INSERT INTO public.laptops( + Product, Price, Diagonal, Resolution, CPU, RAM, Graphics_Controller, Volume, src) + VALUES + ('{productst[i].text.strip()}', '{t.strip()}', '{u[0][:u[0].find("/")]}', '{u[0][u[0].find("/")+1:]}', + '{u[2]}', '{u[4]+" "+u[5]}', '{u[6]}', '{u[8]}', '{filename}');""" + cursor.execute(insert) + connection.commit() + except: + connection.rollback() cursor.close() connection.close() \ No newline at end of file diff --git a/Задания/task1/Lahin/select_and_edit'.py b/Задания/task1/Lahin/select_and_edit'.py new file mode 100644 index 0000000..298ef0b --- /dev/null +++ b/Задания/task1/Lahin/select_and_edit'.py @@ -0,0 +1,27 @@ + +import psycopg2 +import config +def edit(request): + try: + connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password) + cursor = connection.cursor() + cursor.execute(request) + print("Done") + except Exception as error: + print(f"Что-то не так. Ошибка:{error}") + finally: + cursor.close() + connection.close() +def select(request): + try: + connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, + password=config.password) + cursor = connection.cursor() + cursor.execute(request) + result = cursor.fetchall() + except Exception as error: + result = f"Ошибка: {error}" + finally: + cursor.close() + connection.close() + return result \ No newline at end of file diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py index 3031c38..57d6121 100644 --- a/Задания/task1/Lahin/telegrambot.py +++ b/Задания/task1/Lahin/telegrambot.py @@ -1,15 +1,23 @@ import telebot import psycopg2 import config -def execute_request(request): - connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password) - cursor = connection.cursor() - cursor.execute(request) - result = cursor.fetchall() - cursor.close() - connection.close() - return result -max_id = int(execute_request("select count(*) from laptops")[0][0]) +bot = telebot.TeleBot(config.bot_token) + +def select(request): + try: + connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, + password=config.password) + cursor = connection.cursor() + cursor.execute(request) + result = cursor.fetchall() + except: + result = "Ошибка" + finally: + cursor.close() + connection.close() + return result + +max_id = int(select("select max(id) from laptops")[0][0]) bot = telebot.TeleBot(config.bot_token) @bot.message_handler(commands=["start"]) def start(m, res=False): @@ -26,12 +34,21 @@ def from_bd(message): bot.send_message(message.chat.id, "ID больше, чем количество товаров. Попробуйте снова:") return else: - data = execute_request(f"select * from laptops where id = {current_id}")[0][1:-1] - names_of_columns = ["Товар", "Цена", "Диагональ", "Разрешение", "Процессор", "Оперативная память", "Графический контроллер", "Объём диска"] - everydata = [] - for data_name, column_name in zip(data, names_of_columns): - everydata.append(column_name.capitalize() + ": " + data_name) - bot.send_message(message.chat.id, "\n\n".join(everydata)) + try: + data = select(f"select * from laptops where id = {current_id}")[0][1:] + if type(data) == str: + bot.send_message(message.chat.id, "Ошибка на сервере") + return + s = data[:-1] + names_of_columns = ["Товар", "Цена", "Диагональ", "Разрешение", "Процессор", "Оперативная память", + "Графический контроллер", "Объём диска"] + everydata = [] + for data_name, column_name in zip(s, names_of_columns): + everydata.append(column_name.capitalize() + ": " + data_name) + bot.send_message(message.chat.id, "\n\n".join(everydata)) + bot.send_photo(message.chat.id, open(data[-1], 'rb')) + except: + bot.send_message(message.chat.id, "Ошибка на сервере") bot.send_message(message.chat.id, f"Введите следующий ID от 1 до {max_id}:") bot.polling(none_stop=True, interval=0) From 4dcd6465c984be5d31da8cd9b1dcdda447cccd64 Mon Sep 17 00:00:00 2001 From: bumajkaa <124861973+bumajkaa@users.noreply.github.com> Date: Mon, 1 May 2023 20:44:06 +0300 Subject: [PATCH 35/43] Add files via upload --- Задания/task1/Kuranova/bot_beer.py | 85 ++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Задания/task1/Kuranova/bot_beer.py diff --git a/Задания/task1/Kuranova/bot_beer.py b/Задания/task1/Kuranova/bot_beer.py new file mode 100644 index 0000000..844fd7e --- /dev/null +++ b/Задания/task1/Kuranova/bot_beer.py @@ -0,0 +1,85 @@ +import telebot +import random +from telebot import types +import psycopg2 + +bot = telebot.TeleBot('6279990552:AAHxC0hfpQcOrcGKHwvWT7AabQqdE3a5Tp8') + +def request(a): + info = [] + connection = psycopg2.connect(host='localhost', dbname='breweries', user='postgres', password='Q1w2e3r4t5') + cursor = connection.cursor() + cursor.execute(a) + res = cursor.fetchall() + for id, name, place, link in res: + s = [id, name, place, link] + info.append(s) + cursor.close() + connection.close() + return info + +quote = ['В вине есть мудрость, в пиве есть свобода, в воде есть бактерии.\n\nБенджамин Франклин', + 'Пиво — интеллектуальный напиток. Какая досада, что его пьет так много идиотов.\n\nРэй Брэдбери', +'Пьянство — особая форма самоубийства, позволяющая тебе оживать на следующий день. Я, кажется, уже прожил десять или ' +'пятнадцать тысяч жизней.\n\nЧарльз Буковски', +'Я пью, чтобы окружающие меня люди становились интереснее.\n\nДжордж Жан Натан', +'— Уинстон, да вы пьяны!\n— Все верно. А вы уродина. Завтра утром я протрезвею. А вы так и останетесь уродиной.\n\nУинстон Черчилль', +'— Есть в мире вещи получше, чем алкоголь.\n— Да, сэр. Но алкоголь компенсирует их отсутствие.\n\nТерри Пратчетт', +'Если вы заметите человека, который пытается утопить свои горести в стакане, сообщите ему, что горести умеют плавать.\n\nПиттакус Лор', +'Алкоголь, возможно, опаснейший враг человека, но в Библии сказано: возлюби врага своего.\n\nФрэнк Синатра', +'Меня как-то спросили, мучит ли меня похмелье. Нет, ведь для того, чтобы случилось похмелье, нужно перестать пить.\n\nЛемми Килмистер', +'У меня нет проблем с алкоголем. За исключением тех случаев, когда я не могу достать выпивку.\n\nТом Уэйтс', +'Будь осторожен с крепкими напитками. Они могут заставить тебя выстрелить в сборщика налогов… и промахнуться.\n\nРоберт Хайнлайн', +'Плохого виски не бывает. Просто некоторые сорта виски лучше других.\n\nУильям Фолкнер', +'Не всякий, кто пьет, является поэтом. Многие пьют как раз из-за того, что они не поэты.\n\nДадли Мур', +'Компьютер позволяет совершить больше ошибок быстрее, чем какое-либо изобретение в человеческой истории, за исключением, ' +'возможно, револьвера и текилы.\n\nМитч Рэдклифф', +'Я не доверяю верблюдам, и вообще всем, кто может неделю не пить.\n\nДжо Луис', +'Алкоголик — это тип, который тебе не нравится и который пьет столько же, сколько ты.\n\nДилан Томас', +'За алкоголь! Причину и решение всех проблем.\n\nГомер Симпсон'] + +c = request('select id, name, place, imagelink from Information') +def share(message): + a = message.text + b = a.split(',') + connection = psycopg2.connect(host='localhost', dbname='breweries', user='postgres', password='Q1w2e3r4t5') + cursor = connection.cursor() + p = """INSERT INTO Information(id,Name, Place, ImageLink) VALUES + ( '"""+str(int(c[-1][0])+1)+"""', '"""+b[0]+"""', '"""+b[1]+"""', '"""+b[2]+"""');""" + cursor.execute(p) + connection.commit() + cursor.close() + connection.close() + bot.send_message(message.chat.id, 'Вы сделали неоценимую услугу! Спасибо вам большое!') +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup=types.ReplyKeyboardMarkup(resize_keyboard=True) + item1=types.KeyboardButton("Где выпить?") + item2 = types.KeyboardButton("Знаешь еще места, где можно выпить? Поделись)") + item3 = types.KeyboardButton("Хочешь выпить, но нет повода или тоста? Не переживай, мы и такое предусмотрели;)") + markup.add(item1) + markup.add(item2) + markup.add(item3) + bot.send_message(m.chat.id, 'Если не хочешь заморачиваться, то просто нажми любую из предложенных кнопок\n' + f'А можешь ввести число от {c[0][0]} до {c[-1][0]}, мы тебе выведем номер самой ' + f'лучшей пивоварни :)', reply_markup=markup) + +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if message.text.strip() == 'Где выпить?': + choice = random.randint(1, len(c)-1) + bot.send_message(message.chat.id, f'{c[choice]}') + elif message.text.strip().isnumeric(): + try: + bot.send_message(message.chat.id, f'{c[int(message.text) - 1]}') + except: + bot.send_message(message.chat.id, "Кажись, вы попали не в тот интервал. Попробуйте снова.") + elif message.text.strip() == 'Знаешь еще места, где можно выпить? Поделись)': + bot.send_message(message.chat.id, 'Пиши название, адрес, контакты через запятую!') + bot.register_next_step_handler(message, share) + elif message.text.strip() == 'Хочешь выпить, но нет повода или тоста? Не переживай, мы и такое предусмотрели;)': + bot.send_message(message.chat.id, 'Лови!') + choice1 = random.randint(1, len(quote)-1) + bot.send_message(message.chat.id, quote[choice1]) + +bot.polling(none_stop=True, interval=0) \ No newline at end of file From d8897febc54953e7864ae0ae60efbaa461a23835 Mon Sep 17 00:00:00 2001 From: pErfEcto2 Date: Thu, 4 May 2023 11:31:11 +0300 Subject: [PATCH 36/43] django test by perfecto --- .../__pycache__/config.cpython-310.pyc | Bin 0 -> 282 bytes .../__pycache__/db_get_data.cpython-310.pyc | Bin 0 -> 602 bytes .../task1/Yaroshevskiy/test_site/config.py | 5 + .../task1/Yaroshevskiy/test_site/db.sqlite3 | Bin 0 -> 143360 bytes .../Yaroshevskiy/test_site/db_get_data.py | 10 ++ .../task1/Yaroshevskiy/test_site/manage.py | 22 ++++ .../Yaroshevskiy/test_site/polls/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 183 bytes .../polls/__pycache__/admin.cpython-310.pyc | Bin 0 -> 224 bytes .../polls/__pycache__/apps.cpython-310.pyc | Bin 0 -> 460 bytes .../polls/__pycache__/forms.cpython-310.pyc | Bin 0 -> 461 bytes .../polls/__pycache__/models.cpython-310.pyc | Bin 0 -> 805 bytes .../polls/__pycache__/urls.cpython-310.pyc | Bin 0 -> 348 bytes .../polls/__pycache__/views.cpython-310.pyc | Bin 0 -> 560 bytes .../Yaroshevskiy/test_site/polls/admin.py | 3 + .../Yaroshevskiy/test_site/polls/apps.py | 6 + .../Yaroshevskiy/test_site/polls/forms.py | 5 + .../polls/migrations/0001_initial.py | 32 +++++ .../test_site/polls/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-310.pyc | Bin 0 -> 1052 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 194 bytes .../Yaroshevskiy/test_site/polls/models.py | 12 ++ .../test_site/polls/static/polls/style.css | 3 + .../polls/templates/polls/index.html | 11 ++ .../Yaroshevskiy/test_site/polls/tests.py | 3 + .../Yaroshevskiy/test_site/polls/urls.py | 8 ++ .../Yaroshevskiy/test_site/polls/views.py | 15 +++ .../test_site/test_site/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 187 bytes .../__pycache__/settings.cpython-310.pyc | Bin 0 -> 2344 bytes .../__pycache__/urls.cpython-310.pyc | Bin 0 -> 366 bytes .../__pycache__/wsgi.cpython-310.pyc | Bin 0 -> 594 bytes .../Yaroshevskiy/test_site/test_site/asgi.py | 16 +++ .../test_site/test_site/settings.py | 124 ++++++++++++++++++ .../Yaroshevskiy/test_site/test_site/urls.py | 7 + .../Yaroshevskiy/test_site/test_site/wsgi.py | 16 +++ 36 files changed, 298 insertions(+) create mode 100644 Задания/task1/Yaroshevskiy/test_site/__pycache__/config.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/__pycache__/db_get_data.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/config.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/db.sqlite3 create mode 100644 Задания/task1/Yaroshevskiy/test_site/db_get_data.py create mode 100755 Задания/task1/Yaroshevskiy/test_site/manage.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__init__.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/admin.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/apps.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/forms.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/models.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/admin.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/apps.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/forms.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/0001_initial.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/__init__.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/0001_initial.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/__init__.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/models.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/static/polls/style.css create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/templates/polls/index.html create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/tests.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/urls.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/views.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__init__.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/settings.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/wsgi.cpython-310.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/asgi.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/settings.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/urls.py create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/wsgi.py diff --git a/Задания/task1/Yaroshevskiy/test_site/__pycache__/config.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/__pycache__/config.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee62378f62583148bbe7e2abb9f30c194f9b2de0 GIT binary patch literal 282 zcmd1j<>g`kf{D?=DJekuF^Gc<7=auIATAaF5-AK(3@MCJj44b}OexI444N!edS*uE z#wNyQhDH`vj*jlW9%Y`+DNa7=#mR+kx)IKv{-%D383qQ0x`B=sY00ipJSj=>Y57I* z1&Kw)sZksSsYPk2$tC%In#{LYOY*Z*^KP*NRpce+rru&HElw?3$xy@sv>8l%^#`)_ zGxBp&^>b4TGBWiGDoZl*^YoLAjLZ#<^e;@mu;IcMAl`dn$HjjAlEmU{L;c9aqWt2F z)Ux92%u4-|)Z&u(;>?m%{p9?-w9It9g34PQHo5sJr8%i~AfFbq0SOic7Df(60EIwN AL;wH) literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/__pycache__/db_get_data.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/__pycache__/db_get_data.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34bd719ee88fc5c0e90001b802ddc5550b8282da GIT binary patch literal 602 zcmZWmJ&)5s5Zy03Cen$Vgb)=41(KUvB@Gfn2#NlhAfa<(`Mi_ZcaCj#*MOy@0a}!j z_EI8Uam5wa@E=0EEfqh2j<4AiC=xSzZ+B+ij-Kr1;9y8FF4L)El#p+}*bjllGlY4F zq==#wN$Bom2~!NX;vi;12^D-0NucPI#Nl_;l4BRV>Ol7{)L=VZ=eYh~__enX&k^Pw zk|k%&cllp#ag?Y4 literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/config.py b/Задания/task1/Yaroshevskiy/test_site/config.py new file mode 100644 index 0000000..22b3d2f --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/config.py @@ -0,0 +1,5 @@ +# i know i pushed the config file, but i literally don't care +# there is no useful info +token = "6273436128:AAGMHvICdBLgscqF-XCIO5Nah00q-QA8fcE" +db_name = "db_for_parse" +user = "perfecto" diff --git a/Задания/task1/Yaroshevskiy/test_site/db.sqlite3 b/Задания/task1/Yaroshevskiy/test_site/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..a34fefcc5cc793461cd426fc08ae1daf8c220a99 GIT binary patch literal 143360 zcmeI5du$v@UdOvV?U`{rGv#L{FUM_ry~*G>p7$fW%dI!-%bH}J&Fl6ev1)o|+Ro(W z;mnNl&>_TllRLBr{K1KnK!Qa`2oU_iOS(Uflh7fwybqx}Bp!$0uZ0tLhd|u@0Z3F; zS5H4?{8$q~Vtq$SWxD!Tzy8*zs(Pk=RqeTP?MkI>sOybpO>e6yX+)A`=~Y#gBx#oZ zo1_1%*DLgmVja-`WykxS-p)$r*S|T)jLCm8o2dEUPUgr50T2KI5C8!X009sH0T2KI z5C8!Xc=`k;Pll<}@!``F`G9hP1{ zx2PFjAOHd&00JNY0w4eaAaIBY#K#Av==}0#qgrjnaH>($xHN%V@PKjruNy68Q`9?D=>+natdd<*k`a`X1)Hm99+?QvbGUp5VTq+%Zb%c7lWO+(xTbpIQ zZD^a##=}S2rqQfbOkI6FWDDtB`XZqo-n2Z#g_ezGV{3C?GBW9GHgPFJo!k;m;ss}g zs`@_blgj4f$&ZJrqZ^i^ywefGvmY*rd^VTA9HM^SvHawOpZj{XLiseBEln?%HKW;V zG_@LSI(@@v^+S{|>s*R0GU8`?ZJzdRg>wGSoOvPUvqCTv)j;EbIx@;Po?fwcr~2ajWy%eQiIzCZ8;1=rHgPO7oYNofsKK z%D2|I-^HsjzT9bFyoppYomm~E%)R!XXHN00@8p2!H?xfB*=900@8p2!O!e1V)tTahY!;GB+Fq$CT)l znQ?E+XtB9?U_zNXDO($d#Q*+N%KV({+!5h;KNwafCwUlwMF^CLG8yGZJbd6AS0-op zp}iGjV3b~Uh=&BM4H0brzdD?j$lsCQB0oloazem(R!^h2SSLu14LH2js}UmX77;ZINpc!2;2fB*=900@8p2!OyL zC7`NT+O#U&p=)?f zD>Fk_ot~mrGqE7sp>8{(N0ygU+)IF~u_hB;JyyoqlhkS<6%dN7Y=+A{BQmC@B znWfNWWz8O^mh+1Nrp(G?W=xxPJbR4W__;bUsp*On$1g^yO)TLT+8kB_mt}XET0>;dR zL{|a&3f0{l&x zCKNd)dtx*XE21AIl>`}Xhb54JSBI79bpdD5#I=L0*TBCkI3(nFOx5l-z2|Aeu=zKeujLW`~>+d>5xy8Ez%$rQX=n= zx5+hfnL5A=1V8`;KmY_l00ck)1V8`;KmY^|JApx;EC*GdPV@9MPp4QKIK|VGJUzkF z<1Fp^|AOHd&00JNY0w4eaAOHd&00JN&N%;GJ=mj7E0w4ea zAOHd&00JNY0w4eaAaM8zVE%vj+ZZ(j0T2KI5C8!X009sH0T2KI5C8$p|Ir6P00ck) z1V8`;KmY_l00ck)1VG^M6Ttlc@V7B)2m&Ag0w4eaAOHd&00JNY0w4eanE#^>fB*=9 z00@8p2!H?xfB*=900@A<;U^Fd{D(y34-y@O z%hzwKmsf79%eQV`U0tJ&-dtI`c}|^e6z>|Pw#Le}jfZVsz|L+Oo6TAEzTPa|(VJ(J z@p!E3l^W@#cBN6*)~ou)tlFyS)hfNTx>avgHtI&XYpGs*W98yyD$Zs9{jaF;7hdDgC~w<+@J zQl?Z$8eD&m@mQZ`=rQs%uI14ozNbh({0k$2=sQ&Wo4biOJyH0@L^56~t{3|29^IGj z9%p+=whGL~w&TP6*7tav-}=0*?>!C)J>u5qJuSxLN4xb|U7)wr|8C58E4dHH+*YXH z<1Q5&eo=bsX?{#~9!v(KouOrUd&%xG912gIU0$H_bksyz&la<(q-XqkOCQ@~Bzx_< zHws$;zvnrx=ICg=xYvhgh`T(|aXvl~h+d<2s*I=Nyg6EqJ5(-{DP+=VZ+|=5XLxW4 zJ2~*`HSL&6{*K>2x7UJ!XrUlK&e=o4JZsBuaV0&uLw$xvkI{h!Nmt&}?acJHYgdZZ zejo1b0{a{=bg&%l9Wb5z(Ll6BKXY$;8sFQ8y8TcuWDLEWDB8WiYkGXA{@^w2@#*at z-U7~!9P5mX2clPLzfE|g^H#DyVY7N7X_WI0!KT5)PBM2W?-gg7xh35t^d{mf$lG(a zCT{1rSvW?N-H2>V$4li@GE7%jj zPlf`~j9>y=tXxXf5O3mQgPmoVIwEw|%#L zzc=us@_PdprGJ-Fk$;K2^GY%hjm3P|q>lMc-p=rF$Y!HjZD};V(qh37_tA_y5aK?0 zpeTrS9gVFqJ0l)hS3G2MtEjPHN57CqXCe`Z-iXPa0*^C_=uL|*8?!ZNiNB5RHZ{8~j*vi_;SBahQlo6JT5IuyUQFdOy1fQtm+}kIeHLGAqkX#G zcTH%cSmNkDfq6B+76u;6_DHcW&Bu#@*k=!P7x7~59eK{R4{@7x77|z8dyS=A zXM2=-_FK6-Y0|lv5bL}#O?MKdTXV=H5QxGH5)x=iYxGdU{S5F6`sg%53aDJpZOZL$)ZzbM}<3ZSQDK7fVLoD0-!x+(VkP!PtGVB>e0w(NkhJCP}{gdwrDRJP3fm(*>_XKZeN;3g?FE@-fy&xR`1>=`dQ|zf?BN5Z`O2g zb-z8urcldVd`Ru_Z6SvB|EJmE;R^&n00ck)1V8`;KmY_l00ck)1fER-nEyYU?E+OG z00JNY0w4eaAOHd&00JNY0wC}-31I&JG-<*Y2!H?xfB*=900@8p2!H?xfB*U3%sz3k)KmY_l00ck)1V8`;KmY_l;As-T{Qqgvgf9>P0T2KI5C8!X009sH0T2KI z5O_8TgsH3`S(nJS$X}B`CcjJGC-0F5Gy^XX009sH0T2KI5C8!X009sH0T2Lzk4S(7 z6)Ae0|ABt<*8oNXG-HZqSbwm8+^_|NmSy7sP@92!H?xfB*=900@8p N2!H?xfWUzW{0~aLc&7jW literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/db_get_data.py b/Задания/task1/Yaroshevskiy/test_site/db_get_data.py new file mode 100644 index 0000000..acec30b --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/db_get_data.py @@ -0,0 +1,10 @@ +import psycopg2 as ps +import config + + +def exec_query(query: str) -> list: + with ps.connect(dbname=config.db_name, user=config.user) as conn: + with conn.cursor() as cur: + cur.execute(query) + res = cur.fetchall() + return res diff --git a/Задания/task1/Yaroshevskiy/test_site/manage.py b/Задания/task1/Yaroshevskiy/test_site/manage.py new file mode 100755 index 0000000..cceae78 --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_site.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__init__.py b/Задания/task1/Yaroshevskiy/test_site/polls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19f6e7df785c37c4ad54a0aa72e9c0bd78d680f7 GIT binary patch literal 183 zcmd1j<>g`kf-8Q(DIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o1T-$kort&rQ|O zO)bdC)Gw$k$;i*sPc||#H#E|}F#W=Y3tNDA?}Z%~`}Io_i?a>&BNL1Ai!)NoinB8- y^-EHVOX7<&OH%a<@^f;E_2c6+^D;}~g`kf-8Q(DfU46F^Gc(44TX@fuanW zjJH@5Q*tx&{4|-O_)@YG^V0M6lJoOQiZYXmKnAR2C}IXuVB%{CkfooIpPQX)Pz pm&6xmmZa(zw|69E2zB1VUwGmQks)$#|X5c7-X*i0{{d@J!Sv^ literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/apps.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6a4f8c1bd899534b75b67f7511b14192c9c5a0b GIT binary patch literal 460 zcmYjOJx{|h5VhkJrC$qTMPkhot6f+SYC(dnLh3{o%hYZY>ck;Vkje@(jQj>R1_l=X zLy(xVGVuf0Ij5EANq4^Udw#k*>wdq3z`iC^@d)R)Ew;^tVgzmuAP6L|LJ1BrM(0R4 zf;=EWB)%u1Bit$STR*@;KCav2EIZZdJYLM~&9-4EM&M=-f>lInF+F0PC(ag)a*d;kc&Os+)aE^ gcQ<2NZteiyApcFRGy7Y$ceI}F*zVF;!5-Qpe=sO_qyPW_ literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/forms.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a8ab7244e3a3f7a65f914bf0e8967afbcb0c847 GIT binary patch literal 461 zcmYk2y-ve05PAx;tPgaj*Msv3w8<$-|0GE&B!KTTrab_ZU19sYH-OWKm4AWf7^AO#1!9UZ0dtv_B+c4DgILXb>JsY!K=gKU|*0Jb;K*7#@}SD9hpnI@mH ebgJqJJ-c{S`X8$HI?!kQqk6q#{EO|GE>u+l!w%*W0 z00UmIk|&(A#|#{B-!gEK&z(1J;!>mo9!0#HNC*508wA(%k`1`=O9@!0sdYD(OU^!R zb(a8H!ht0Yy7LZja4vb`q5HuH_ajdN=ukq>gwL0#bS|rFMm=9~(<{>pQD8OG+3Rgc zHQre)Pl{Y+2;)I$LLsWOL?KL124SUVEpY?&7AN$pT^(;a1LeUxJXN&oDohR}GS zP5+RxzQ{{#PeaNtY@sVwNA$9RpT}gynJh6bagpWmVx==##na*N{@yTNzh8e^f2RF) z{pH)cSf}cAFMgTUlG;31r}-+@^edrqjqySjg^F9kb{DJKa%81YK0(MLzRjE1KV<%; z*Cv@rG|qkCmrfFp64N!FE>Ak9!?Z4=j?1)|)_834XY zmxUe=qB^kg&_dTj!)5PC)|k(#r`Wb{g3-Zbba41634c>t+u2LDrcJq)=jchLafYo3 z#ygk9$sdMWt8Z&;6WC(PmJQhskN6I6qGOtnF3i(vCU@baZN__MXRo2Gx%0o2CVbG& Q#zXtVhUtjia&LRT0E!dBnE(I) literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2fb33ab12360ad3401afe4626fd96c89647407ce GIT binary patch literal 348 zcmYk2zfQw25QpvjYiQHHN0wU6!crlgfF%=IP{f^@v`HM9^b}y>d*1x>q(eW?^fcrR8m)X(7SpNF3p{;4T@eijTSD(vL9@` WZYAs+ymHUc?kf|P@I|oT@y{>B0bWl4 literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d334b65167238329dad474fc41992524547fb7c GIT binary patch literal 560 zcmZ8eu};G<5VaGh4Kzg^`GrWRR=cnugv7$sfwGVVRk1}vlQ`IJX;GQV&d4`(V_;z6 zAHo_&CO&`}&MrcLrF*%{`R?93i*|bx!Ff%GEW`-Cnc(+vAUFV1I{*wZoS_^?7#rWo zoZO9E@Lfi3QAC)>8u0a4bBIF!9V*ZY*TIq2~}xj&z}35`fUDo04Bn z;9}j3MPcezNNzyt;{<>vBIh*cWs=fzt`kwvxZmIH^=WlqJyefi&(+h*9n~W>?$Ohc z6e{6UHBRT$Og~ep=5)fgc5cRH|#QE$8rNE5?LJEht?FAtr)RIzEp;khzknqKFGZSZB+w0m+)$|Bl zBaZw9xN+dXh5rz)d*#$0fVe=#*hwfzthM8PyP7vMZ+2y~S<`5|dT{^`3{Cr%gTDvu zX`3|D4jIsZ1zN~#7IK@j9P>c8ji(yuV7$@5K<1ZT>vjqFfz~cvkdM~psul__aWf&K zRFy*s7^M5X{Os>hC$LE~eNP58n}KF?V7BgQwt*$T3>>!q7W()~0&79)$q%$!tYXcf9yR~O$}TU%RqW-4^z zQIfx`3eEH`8B;SjeFkSMyv16K|1vHObB=B@{?oWLe-u9LvZ_vt>%dVV;8e3)e>OYQ lC)Sylo!p@ah3{3R)73pXQ0BvF&mQHsAT5(wg`kf-8Q(DIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o1Tq$kort&rQ|O zO)bdC)Gw$k$;i*sPc||#H#E|}F#W=Y3tNDA?}Z%~`}Io_i?a>&BNL1Ai!)NoinB8- z^-EHVOX7<&OH%a<@^f;E^>Z`RixNvR^Ye=J + + + {% load static %} + + TEST + + +

{{text}}

+ + diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/tests.py b/Задания/task1/Yaroshevskiy/test_site/polls/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/polls/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/urls.py b/Задания/task1/Yaroshevskiy/test_site/polls/urls.py new file mode 100644 index 0000000..7c211a3 --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/polls/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + + +urlpatterns = [ + path("", views.index, name="index"), + path("test", views.test, name="other") +] diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/views.py b/Задания/task1/Yaroshevskiy/test_site/polls/views.py new file mode 100644 index 0000000..51a63de --- /dev/null +++ b/Задания/task1/Yaroshevskiy/test_site/polls/views.py @@ -0,0 +1,15 @@ +from django.http import HttpResponse +from django.shortcuts import render +# from db_get_data import exec_query + + +def index(request): + context = { + "text": "test" + } + + return HttpResponse(render(request, "polls/index.html", context)) + + +def test(req): + return HttpResponse("test") diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__init__.py b/Задания/task1/Yaroshevskiy/test_site/test_site/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eb0fd5283065483d8a01ede1c68c42111adc3393 GIT binary patch literal 187 zcmd1j<>g`kf_c8dDIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o1T*$kort&rQ|O zO)bdC)Gw$k$;i*sPc||#H#E|}F#W=Y3tNDA?}Z%~`}Io_i?a>&BNL1Ai!)NoinB8- t^-EHVOX7<&OHz?o@$s2?nI-Y@dIgoYIBatBQ%ZAE?LhVxGXV(}1^`pzGlu{G literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/settings.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0158adf9571f0a5fa7cc9b595935751205c1f044 GIT binary patch literal 2344 zcmb7FOK;mo5GH9_QWV?qBd;bXz#u?lH8lx4MiLZ78d{IPUlKW%A0v%Tu`Nk1!z4-#UHrdY;V@gpcylZL^Idn z%u5{(&A#EyJUlb-yo|Eu90CmzQL4+o;R%l}zZN^ZIgjSd1vHNqa0Xqu&7sBD0^!Xo zXbCNY%@SG}j#r1{HNtm9a}ixPm(UG!8KSMgeHGm_ub~gj>*$uw6>i%y&vE%u&-Ock zL@{H;?@*~7L=wZ4S(Gp=g;CJM4wLiw9qi-CW*AAWBk3L*dac>WBfdnL9kH?HJ*iIt zM;gO!${X@Jcy9x$7erVhJ_PV=Mgm`gKkE_*NnHF1WPtNs#zOk3qM*Q`@+ihh22S89 z*jE5hVL?b7s+^>(jNn-pOYOevN-m*H3fgB&vV8=BFo~o?+wEiee_}+*j}!{ zCt|~9-FR!v0`Vz!`Vn3mIIH)g`0mq>dY#AYjuX+=W)uhP>u7NQ72ZUvgGYtUyGMsH z>pWzuaqmul)hJ}+>tW!!RJOyA%8hhd4E#3f#8*e~vJ?0$A}x7HcDynz?L#KFr-Z2s z_8B`0F^z9bDJiBD=s&OUKw)>lzr@_YIJD z!(Qk@56Ue7z&<+Z5xF#MM`Ns}$?~uOUNH;0$APqhh!(_nbsFZpm5gw!--$oIfMtYV zLNBrS{@C`kOjAzZgPd|5KbSH;5dc!E! zYkGX^jIsgkkhGhC>ESjeS%lkm-({zDjap|6(w8nAbPwV@2*>k+kYu#lPPwKfVoj}T zQF{2t&!$oz)=p?sItU_U!O23cb zsJgyi-z`~tYNZUyI@I8NMXl{L)g8?$)=L@ymaCd&)}dx{O-Q)B{LdO(hp(>|D(oqQ?f@F>ZB23ym2@e}y?bMy-s zL~d?waYoFFGop~2&E>_sAPT&|=LF%M__z2@TokebpW(%SU_K8rapL|ewp0t Ezsfc&B>(^b literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e1930886dcc286a7b1c85a07fb913a73e518ad7b GIT binary patch literal 366 zcmYk1zfQw25XNoCNvr-ryhfH-?ZQ$ao`8W4h%6}7R+H9_Biltv*E|3t55UC6z`()_ zFoo4C6A!?OI9Cik={|q=)9F50Pp2aU^>MZ2Pw;+);kaTLE}-oKgd>h6QaHyrcp{04 z@<`E~Vk9CS3A~9nNk_m_L3!Naj;u*O;K>rDgKxNiQtab`tEx_kr%mBXKd9=J+;Oo_ z4xD+kA2nJ^o9&FWm+3G+;hUmf>ujZKXR13x;Eo^v!?0u`Ach7^ZRLcgf%-8hL^xq; z`;1KZ=s|w2!Ld>+!IWsqiZ!h(b@h7cPvC+HMUq6r@U{s9fxX;}aO literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/wsgi.cpython-310.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..68bbf572f3da17f755ea9b1e8a6b6144f8bce2ec GIT binary patch literal 594 zcmYjPv2GJV5ZyaFaX1J<2vKiq32upngoF?RDZw%#PH{mIZqCc?*tgE!&gpjJ;Ixz! zlynG6ItmIJ{=t-7OT`D!GiQs)BhBp0j%MDQoyFbVh>?6eOw_x8vENOwDQya#kh*(h z6dN%WsL%wXfXG9#g+(gi~MzTw8)HRtb)lnrp`=+Q1#|0HWOc(mfPHVdi2rlXi;#Ib~P~ zu;PB)6FHuH6bed%ivp|{=WeP+^oJgV4ZA^oYYIMX?$Qk!_3i!VPlx@ZG&wjv9t`_Q zdU&+|^2Nc$&CB^?2i|Ktb=^+gNmC+`rgey}zOkkfXEZ_FG_FE|sykrkx Date: Sun, 7 May 2023 16:54:06 +0300 Subject: [PATCH 37/43] Add files via upload --- Задания/task1/Markovich/db.py | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Задания/task1/Markovich/db.py diff --git a/Задания/task1/Markovich/db.py b/Задания/task1/Markovich/db.py new file mode 100644 index 0000000..e5f1c19 --- /dev/null +++ b/Задания/task1/Markovich/db.py @@ -0,0 +1,49 @@ +import telebot +import psycopg2 +from telebot import types +import random + +connection = psycopg2.connect(dbname='dbdata', user='postgres',password='Q1w2e3r4', host='localhost') +cursor = connection.cursor() + + +sel_query = """SELECT * FROM public.pizza""" +cursor.execute(sel_query) +array = list(cursor.fetchall()) + +bot = telebot.TeleBot('6161398146:AAEY99Cox8omow3OnURN_mwXDOpAOfTp09w') + +@bot.message_handler(commands=["start"]) +def start(m, res=False): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Хочу пирог!") + item2 = types.KeyboardButton("Какова цена?") + item3 = types.KeyboardButton("Описание") + markup.add(item1) + markup.add(item2) + markup.add(item3) + bot.send_message( + m.chat.id, '"Хочу пирог!" - для получения пирога\n "Какова цена?" - для получения цены\n "Описание" - описание', + reply_markup=markup) + +i = random.choice(array) +@bot.message_handler(content_types=["text"]) +def handle_text(message): + if (message.text.strip() == 'Хочу пирог!'): + ans = f'{i[1]}\n' + bot.send_message(message.chat.id, ans) + try: + bot.send_photo(message.chat.id, open(i[4], 'rb')) + except telebot.apihelper.ApiTelegramException: + bot.send_message(message.chat.id, "Проблемы с загрузкой картинки....Продолжайте") + elif (message.text.strip() == 'Какова цена?'): + ans = f'{i[3]}\n' + bot.send_message(message.chat.id, ans) + elif (message.text.strip() == 'Описание'): + ans = f'{i[2]}\n' + bot.send_message(message.chat.id, ans) + +bot.polling(none_stop=True, interval=0) + +cursor.close() +connection.close() \ No newline at end of file From f985f9b2d54be3b3b6b3ad82625cfc2d7a51b454 Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Tue, 9 May 2023 02:58:15 +0300 Subject: [PATCH 38/43] Update parcing.py --- Задания/task1/Uskova/parcing.py | 43 ++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/Задания/task1/Uskova/parcing.py b/Задания/task1/Uskova/parcing.py index 17aeb52..c989b42 100644 --- a/Задания/task1/Uskova/parcing.py +++ b/Задания/task1/Uskova/parcing.py @@ -1,14 +1,35 @@ from bs4 import BeautifulSoup -from selenium.webdriver import Chrome from selenium import webdriver from selenium.webdriver.chrome.service import Service -import time -s = Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32\\chromedriver.exe') -browser = webdriver.Chrome(service=s) -browser.get('https://www.citilink.ru/catalog/noutbuki/') -html_text = browser.page_source -soup = BeautifulSoup(html_text, 'lxml') -name=soup.find_all('div', class_='app-catalog-1tp0ino e1an64qs0') -print (name[0].text) -description=soup.find_all('div', class_='app-catalog-1o4umte eevw8x70') -print (description[0].text) +import psycopg2 +import wget + +browser = webdriver.Chrome(service=Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32.zip\\chromedriver.exe')) +browser.get('https://msk.sushi-market.com/menu/rolly') +soup = BeautifulSoup(browser.page_source, "lxml") + +Name = soup.find_all(attrs={"class": "goodsBlockName device-show"}) +Info = soup.find_all(attrs={"class": "goodsBlockWeight"}) +Des = soup.find_all(attrs={"class": "cardsList_text"}) +Price = soup.find_all(attrs={"class": "goodsBlockPrice"}) +Image = soup.find_all(attrs={"class": "cardsList_img add-to-cart__img"}) + +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') +cursor = connection.cursor() +create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(5000), Info varchar(5000), Des varchar(10000), Price varchar(6000), src varchar(1000))''' +cursor.execute(create_q) +connection.commit() + +for j in range(25): + url = Image[j].find('img').attrs['src'] + tempf = f"img\\food{j}.jpg" + wget.download(url, tempf) + insert_query = f'''INSERT into public.Food(Name, Info, Des, Price, src) values ('{Name[j].text}','{Info[j].text}','{Des[j].text}', '{Price[j].text}', '{tempf}') ''' + cursor.execute(insert_query) +connection.commit() + +cursor.execute("SELECT * from Food") +print(cursor.fetchall()) + +cursor.close() +connection.close() From 8a4ba475d02ef456804b595ad1a4c0c3360570c0 Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Tue, 9 May 2023 02:58:51 +0300 Subject: [PATCH 39/43] Update DataBaze.py --- Задания/task1/Uskova/DataBaze.py | 46 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/Задания/task1/Uskova/DataBaze.py b/Задания/task1/Uskova/DataBaze.py index bdd3ded..c989b42 100644 --- a/Задания/task1/Uskova/DataBaze.py +++ b/Задания/task1/Uskova/DataBaze.py @@ -4,36 +4,32 @@ from selenium.webdriver.chrome.service import Service import psycopg2 import wget +browser = webdriver.Chrome(service=Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32.zip\\chromedriver.exe')) +browser.get('https://msk.sushi-market.com/menu/rolly') +soup = BeautifulSoup(browser.page_source, "lxml") + +Name = soup.find_all(attrs={"class": "goodsBlockName device-show"}) +Info = soup.find_all(attrs={"class": "goodsBlockWeight"}) +Des = soup.find_all(attrs={"class": "cardsList_text"}) +Price = soup.find_all(attrs={"class": "goodsBlockPrice"}) +Image = soup.find_all(attrs={"class": "cardsList_img add-to-cart__img"}) + connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() - -crtable = """ create table Notebooks - (id serial primary key, name varchar(500), description varchar(500), code varchar(200), price varchar(100), - picture varchar(500)) """ - -cursor.execute(crtable) +create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(5000), Info varchar(5000), Des varchar(10000), Price varchar(6000), src varchar(1000))''' +cursor.execute(create_q) connection.commit() -s = Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32\\chromedriver.exe') -browser = webdriver.Chrome(service=s) -browser.get('https://www.citilink.ru/catalog/noutbuki/') -html_text = browser.page_source -soup = BeautifulSoup(html_text, 'lxml') +for j in range(25): + url = Image[j].find('img').attrs['src'] + tempf = f"img\\food{j}.jpg" + wget.download(url, tempf) + insert_query = f'''INSERT into public.Food(Name, Info, Des, Price, src) values ('{Name[j].text}','{Info[j].text}','{Des[j].text}', '{Price[j].text}', '{tempf}') ''' + cursor.execute(insert_query) +connection.commit() -name = soup.find_all('div', class_='app-catalog-1tp0ino e1an64qs0') -description = soup.find_all('div', class_='app-catalog-1o4umte eevw8x70') -code = soup.find_all('div', class_= 'app-catalog-0 e1dsj6g20') -price = soup.find_all('div', class_= 'app-catalog-0 e1dsj6g20') -picture = soup.find_all('div', class_='app-catalog-0 e1jarwcz0') - -for i in range(len(name)): - url = picture[i].find('img').attrs['src'] - file = f"C:\\Users\\Yekaterina\\Desktop\\baza\\pic{i}.JPG" - wget.download(url, file) - ins_qwery = f"""insert into public.Notebooks(name, description, code, price, picture) - values ('{name[i].text}', '{description[i].text}', '{code[i].text}', '{price[i].text}','{file}')""" - cursor.execute(ins_qwery) - connection.commit() +cursor.execute("SELECT * from Food") +print(cursor.fetchall()) cursor.close() connection.close() From 2e9837fdf4fdfcdd936079b2834dc6cfccf3ba69 Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Tue, 9 May 2023 02:59:26 +0300 Subject: [PATCH 40/43] Update parcing.py --- Задания/task1/Uskova/parcing.py | 41 +++++++++------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/Задания/task1/Uskova/parcing.py b/Задания/task1/Uskova/parcing.py index c989b42..5c406ad 100644 --- a/Задания/task1/Uskova/parcing.py +++ b/Задания/task1/Uskova/parcing.py @@ -1,35 +1,16 @@ from bs4 import BeautifulSoup +from selenium.webdriver import Chrome from selenium import webdriver from selenium.webdriver.chrome.service import Service -import psycopg2 -import wget +import time +s = Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32\\chromedriver.exe') +browser = webdriver.Chrome(service=s) +browser.get('https://www.citilink.ru/catalog/noutbuki/') +html_text = browser.page_source +soup = BeautifulSoup(html_text, 'lxml') -browser = webdriver.Chrome(service=Service('C:\\Users\\Yekaterina\\Downloads\\chromedriver_win32.zip\\chromedriver.exe')) -browser.get('https://msk.sushi-market.com/menu/rolly') -soup = BeautifulSoup(browser.page_source, "lxml") -Name = soup.find_all(attrs={"class": "goodsBlockName device-show"}) -Info = soup.find_all(attrs={"class": "goodsBlockWeight"}) -Des = soup.find_all(attrs={"class": "cardsList_text"}) -Price = soup.find_all(attrs={"class": "goodsBlockPrice"}) -Image = soup.find_all(attrs={"class": "cardsList_img add-to-cart__img"}) - -connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') -cursor = connection.cursor() -create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(5000), Info varchar(5000), Des varchar(10000), Price varchar(6000), src varchar(1000))''' -cursor.execute(create_q) -connection.commit() - -for j in range(25): - url = Image[j].find('img').attrs['src'] - tempf = f"img\\food{j}.jpg" - wget.download(url, tempf) - insert_query = f'''INSERT into public.Food(Name, Info, Des, Price, src) values ('{Name[j].text}','{Info[j].text}','{Des[j].text}', '{Price[j].text}', '{tempf}') ''' - cursor.execute(insert_query) -connection.commit() - -cursor.execute("SELECT * from Food") -print(cursor.fetchall()) - -cursor.close() -connection.close() +name=soup.find_all('div', class_='app-catalog-1tp0ino e1an64qs0') +print (name[1].text) +description=soup.find_all('div', class_='app-catalog-1o4umte eevw8x70') +print (description[1].text) From ba4992e667f88d967cb3cdab9a85aec0a622ce46 Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Tue, 9 May 2023 03:25:55 +0300 Subject: [PATCH 41/43] Update DataBaze.py --- Задания/task1/Uskova/DataBaze.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Задания/task1/Uskova/DataBaze.py b/Задания/task1/Uskova/DataBaze.py index c989b42..87851d1 100644 --- a/Задания/task1/Uskova/DataBaze.py +++ b/Задания/task1/Uskova/DataBaze.py @@ -11,12 +11,12 @@ soup = BeautifulSoup(browser.page_source, "lxml") Name = soup.find_all(attrs={"class": "goodsBlockName device-show"}) Info = soup.find_all(attrs={"class": "goodsBlockWeight"}) Des = soup.find_all(attrs={"class": "cardsList_text"}) -Price = soup.find_all(attrs={"class": "goodsBlockPrice"}) +Price = soup.find_all(attrs={"class": "product__price updated"}) Image = soup.find_all(attrs={"class": "cardsList_img add-to-cart__img"}) connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() -create_q = '''CREATE TABLE Food (ID serial primary key, Name varchar(5000), Info varchar(5000), Des varchar(10000), Price varchar(6000), src varchar(1000))''' +create_q = '''CREATE TABLE F0ood (ID serial primary key, Name varchar(5000), Info varchar(5000), Des varchar(10000), Price varchar(600), src varchar(1000))''' cursor.execute(create_q) connection.commit() @@ -24,11 +24,11 @@ for j in range(25): url = Image[j].find('img').attrs['src'] tempf = f"img\\food{j}.jpg" wget.download(url, tempf) - insert_query = f'''INSERT into public.Food(Name, Info, Des, Price, src) values ('{Name[j].text}','{Info[j].text}','{Des[j].text}', '{Price[j].text}', '{tempf}') ''' + insert_query = f'''INSERT into public.F0ood(Name, Info, Des, Price, src) values ('{Name[j].text}','{Info[j].text}','{Des[j].text}', '{Price[j].text}', '{tempf}') ''' cursor.execute(insert_query) connection.commit() -cursor.execute("SELECT * from Food") +cursor.execute("SELECT * from F0ood") print(cursor.fetchall()) cursor.close() From 178b051175bb6d5667511a90f52ecccd4286ae13 Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Tue, 9 May 2023 03:27:04 +0300 Subject: [PATCH 42/43] Update bott.py --- Задания/task1/Uskova/bott.py | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/Задания/task1/Uskova/bott.py b/Задания/task1/Uskova/bott.py index 47436e0..4aa410c 100644 --- a/Задания/task1/Uskova/bott.py +++ b/Задания/task1/Uskova/bott.py @@ -1,36 +1,43 @@ import telebot import psycopg2 -import config from telebot import types import random -import tableCreator -connection = psycopg2.connect(host='localhost', dbname='parc', user='postgres', password='Q1w2e3r4') +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() +try: + sel_query = """SELECT * FROM public.f0ood""" + cursor.execute(sel_query) +except psycopg2.errors.UndefinedTable: + connection.rollback() + import problems + sel_query = """SELECT * FROM public.f0ood""" + cursor.execute(sel_query) -ins_query = """SELECT * FROM public.Notebooks""" -cursor.execute(ins_query) array = list(cursor.fetchall()) +bot = telebot.TeleBot('6280771915:AAG2rcsqHZbUjeaOD-llwR-UU-LabMprKBo') -bot = telebot.TeleBot('6205726630:AAF4zfV_P2b0f7bClm__sWuRmoZ1XpiC_xo') @bot.message_handler(commands=["start"]) - def start(m, res=False): - markup=types.ReplyKeyboardMarkup(resize_keyboard=True) - item1=types.KeyboardButton("Выбери ноутбук") - item2=types.KeyboardButton("Еще!") - markup.add(item1) - markup.add(item2) - bot.send_message(m.chat.id, 'Нажми: \nВыбери ноутбук' - ' для просмотра товара\nЕще! ' - '— для повтора', reply_markup=markup) + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + item1 = types.KeyboardButton("Роллы") + item2 = types.KeyboardButton("Хочу еще!") + markup.add(item1) + markup.add(item2) + bot.send_message(m.chat.id, + '"Роллы" - получите случайную порцию роллов\n' + ' "Хочу еще!" - вдруг вы не наелись', reply_markup=markup) + +i = random.choice(array) @bot.message_handler(content_types=["text"]) def handle_text(message): - if message.text.strip() == 'Выбери ноутбук' : - q = random.choice(array) - answer = f'Название: {q[1]}\nОписание: {q[2]}\nКод: {q[3]}\nЦена: {q[4]}\n' - bot.send_message(message.chat.id, answer) - bot.send_picture(message.chat.id, open(q[5], 'rb')) - elif message.text.strip() == 'Еще!': - bot.send_message(message.chat.id, 'Ввод: '+ message.text) + global i + if (message.text.strip() == 'Роллы'): + i = random.choice(array) + ans = f'Название: {i[1]}\nГраммы: {i[2]}\nОписание: {i[3]}\nЦена за 4 штуки: {i[4]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[5], 'rb')) + elif (message.text.strip() == 'Хочу еще!'): + bot.send_message(message.chat.id, 'Ввод: ' + message.text) + bot.polling(none_stop=True, interval=0) From 8dab84f38d50bb293cdaae4b51f14d29440d13fb Mon Sep 17 00:00:00 2001 From: pErfEcto2 Date: Thu, 11 May 2023 11:08:00 +0300 Subject: [PATCH 43/43] mutable template added --- .../polls/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 199 bytes .../polls/__pycache__/admin.cpython-311.pyc | Bin 0 -> 254 bytes .../polls/__pycache__/apps.cpython-311.pyc | Bin 0 -> 568 bytes .../polls/__pycache__/models.cpython-311.pyc | Bin 0 -> 1208 bytes .../polls/__pycache__/urls.cpython-311.pyc | Bin 0 -> 483 bytes .../polls/__pycache__/views.cpython-311.pyc | Bin 0 -> 811 bytes .../__pycache__/0001_initial.cpython-311.pyc | Bin 0 -> 1667 bytes .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 210 bytes .../test_site/polls/static/polls/style.css | 6 ++++++ .../test_site/polls/templates/polls/index.html | 14 ++++++++++++-- .../task1/Yaroshevskiy/test_site/polls/views.py | 3 ++- .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 203 bytes .../__pycache__/settings.cpython-311.pyc | Bin 0 -> 2662 bytes .../test_site/__pycache__/urls.cpython-311.pyc | Bin 0 -> 521 bytes .../test_site/__pycache__/wsgi.cpython-311.pyc | Bin 0 -> 729 bytes 15 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/admin.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/apps.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/models.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/0001_initial.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/__init__.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/settings.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-311.pyc create mode 100644 Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/wsgi.cpython-311.pyc diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a743e8d5aa26b19417e58b454113f701b61f6fc9 GIT binary patch literal 199 zcmZ3^%ge<81XuimQ$X}%5CH>>P{wCAAY(d13PUi1CZpdZvy% literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/admin.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0bbb505773382e37111708d69e030fb950456c77 GIT binary patch literal 254 zcmZ3^%ge<81XuimQ|y8CV-N=hn4pZ$LO{lJh7^Vr#vF!R#wbQch7_h?22JLdAO)I? zw^$QXax?S%G?{MkrDP@MrRVD<=jW9aWhNCd0~M@f_zY6_H3UfLXXNLm>gT2wWMt|W zRF-7q=jkUK8JQaz>0g+BVZ((jK)mJC5gq^hWe3-Mft@Usb$64nU(q_sl_Gn z#hE3k`UUwpImP;5OZ5sWe{tC4=BJeAq}mm60IgsI;$m4K@qw9YaqOBFFQ0U;`m?ei@bP&NG=pYoKlUa_~ySCB%GM5T!?WWj^Yp;-I=(^o4cDj4;l{e%S?fjqmdzZR6auMj=!ImG z5YKWMAxV)CA?-PmPZM&~vz)wAp{#B7oQPP$fV5KwP1bH;EU)&_6o9+F%dpFWu8o6! z)b%~ws@Inm>o^|7ck#WLkMYCP1&%C!xQO?x(C1xt%n$88ju?*!wCYI}mSe3tELBc7$srTqEQD3tBatfnPPg)@SEPOfARUJYkO jD!a^g1dLRK&=3~l-`{9LL31Pc3zzzv+Y1sEnk(( literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/models.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..37c1c2fd9c65a6d4ab7c8b231f481fcb446fea88 GIT binary patch literal 1208 zcmaJ=zfaph6uz_L{KBc*C_{%zAV8HuB`l&qm#PvnZ6WR&niT$xc^v% zPta6gkf# z9PAN$LmxpQ5}I?Pt95Kzimsgla`_m#@v6KlsaPvpm3McLY~it5eN$D;3PvmGs2i0e zO|D`|a^sRj@~x|M%}dfwT~>XKL34Ivxr%HQ6s#gQu``SzS$NlS6M5qGrBcPdHcI?U zG|({^&~$&S6A&wU6^m6|t0-cvX;pMhEM+o}XELIFV4vD&WPY{3bU%ugY;MnpuVh0f z88*yqr72qEL6WIhSgh%)YKneUr)y1vvg!e?oH<9Jbv1ga$^C+pnmlFgRJNPSI;m`H zxhG7t8;&qxPiDKqtRu{}7U?kV1&*$974R`=5%s^g!W?1likA*NBrSAu)kejL$6J&* z@B}fPo6N;L3$Jyl2?}+%8{CfgZRLh@6=)3D|nN0$H7DCtq5A5r|ewcxCeQ+DvjlK65^!)O-GS0$BeQ+Dv Q8+)%W==tSel-_H80axrFnE(I) literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9f5cb9ed863c2fdc6a602f5b376feecf4d718cdb GIT binary patch literal 483 zcmZ8cy-xx$6mRc(a6nL_(ZRT1V4#7;#W*>;5C?HEr){`{`$~I&Y>W&hI+&oFlg8-a z;Nar_P!a}ms}mauadEO08SwSJU*E^CeeXTy^I0IJQ>~Iad4H;4A*nxS){xEs5I~>@ zd{~1J5RK@b=Ib>b0u4||5Y-!K@sJoVsRtc^XK8c!<)kIYSY(L#pHtUrDUzvzLUy7^ z1(=}7j-3gd2S(ea9iD*1a05awR5`GHnxL5SI5EQ5q3p1bPI9DS2lcSjVjgE|0H*d} zsxeC|$VfJhjh!&S=atHCxq`(&yoxtzAL4y@ zg=3pH%lO!4A$Mq-H{C8)gPd|VrZ@^ck7G4KDe8Wkdwxh-9^GeavV&TOpGlbN5W+Fo z5z9IT8)8|fCNMI+gZ_H|=9aroErM7*2}5G HR%DwWmsWrJ literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8a8c17bacbfb78af579a60a84884f3ceb7e6dfe GIT binary patch literal 811 zcmZWm&ubGw6n?Y6QnIaG1Z!>y=)rjC(p(B6o*L^Z2lZkQBxZ*0+THASX3{p&LJrle)8~B>5T1Y8y zw$;THX`vl;6kRB#DwT_u_;I}`WNye}&v)aV^rDX2uGLmoYHl(}ekQ-rekUixkFIQq z%@y}mi$}s^+hWu2xvH->!k5hb-^jMlcEobrOU=9`zKHoPG_i`%hd<8JnRDk;`*ZP2 zF*Ef=D+7f7`b81uOW&-6o#erzll5U~ZB$wt+VzoLPmKB)sW3AErIoUA1z`X)`jZ>_ zX$`JM#uWocs-qS{&8Na|sc?R$K=mpdgg%_vcMq(gT^`xx#3*wWY*ek(rteVN2!)n$ zu5ap0BEpNfYZOOU6tt3Tw#FK|{NDJOLbxn*wyo#=!2wgkc;o^j2z7c3}5Hxtm zH9~E`e4-_f-AcKB+9ZN8C#H)$PnBz7+-;3FbF>?51ilJF|rBK-DdF-#Il z-!bH-g%k%tGG|(9Pq7B_J{pjijVx8s)FVU^hsfG9Y$WSS50T`-)R63;C(bKCOH$-$ zuP9Gs4e4#CLqxN`CqruTD8*=jikfP75G-<5k_JOtE9{#RS}M{YZLWI9P@9O%HT|z| zm_!Z@2iX>@9JL>XsHOBZhlqjuqm*fAnq3NHYBgr)GVN02Ai_Jw{bH7gvJYC8NnDm` z3->id`GhPV^c9U^pi)%TRfmR35)he4he&U#)G@mjWUlV#<{oQ)i!~@oY^d#Znzbzk zoy6)L#hS3mO&aSXwTC8RVq14m8%;OkTZVxm%t(NA$#ymg-W@MY!(&fPgVbaQt`;XiNVhKzL!=j?ILc5^mPJLj1K zUaCG{c9*K7CSKYYFKxI>8#rC3hjG60?6I4#;4dHG{LVPPrsJFRqRkSKY-` zoUZw3N(@bDbo2KGx3=xpzH@60EE_m)j`OCQH*xyFi$xeTkwK&6k`eEEHY*%|%^vI1 zAcsYP#3scq!9BmBCOxz;TP#g}tEHd~tmWXW^$FvAQ!AAFNBn%!zF$~nDzg8ey+?@` o;yBI|09VA|<9FY4P{6_K2@9Oyfp^JC+)dwp%{DIoW7o&<24Tv^AOHXW literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/__init__.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/polls/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..79d01249fac8fedfcc6898608434982e69009b37 GIT binary patch literal 210 zcmZ3^%ge<81XuimQ$X}%5CH>>P{wCAAY(d13PUi1CZpdvgwxvQ8TNPJ*sWMurn03(W+fnosD(>s>{ literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/static/polls/style.css b/Задания/task1/Yaroshevskiy/test_site/polls/static/polls/style.css index dda2cdf..01c2338 100644 --- a/Задания/task1/Yaroshevskiy/test_site/polls/static/polls/style.css +++ b/Задания/task1/Yaroshevskiy/test_site/polls/static/polls/style.css @@ -1,3 +1,9 @@ h1 { color: green; } +table, tr, th { + width: 50%; + border: 1px solid; + margin-left: auto; + margin-right: auto; +} diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/templates/polls/index.html b/Задания/task1/Yaroshevskiy/test_site/polls/templates/polls/index.html index 879b0cb..dcf7be9 100644 --- a/Задания/task1/Yaroshevskiy/test_site/polls/templates/polls/index.html +++ b/Задания/task1/Yaroshevskiy/test_site/polls/templates/polls/index.html @@ -1,4 +1,4 @@ - + {% load static %} @@ -6,6 +6,16 @@ TEST -

{{text}}

+

{{ text }}

+ + + {% for i in list %} + + + + + {% endfor %} +
{{ i }}{% widthratio i 1 i %}
+ diff --git a/Задания/task1/Yaroshevskiy/test_site/polls/views.py b/Задания/task1/Yaroshevskiy/test_site/polls/views.py index 51a63de..908c983 100644 --- a/Задания/task1/Yaroshevskiy/test_site/polls/views.py +++ b/Задания/task1/Yaroshevskiy/test_site/polls/views.py @@ -5,7 +5,8 @@ from django.shortcuts import render def index(request): context = { - "text": "test" + "text": "test", + "list": range(101) } return HttpResponse(render(request, "polls/index.html", context)) diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6ad9f3ca80ef798b2fab648621fa3730bc9a03cf GIT binary patch literal 203 zcmZ3^%ge<81oM1@Q$X}%5CH>>P{wCAAY(d13PUi1CZpd35h_cnDJLx#Sc2A!rE&P7 zaz=5@la9N<0`09m^icHB#iExUdg!J9gHsgPfF}dJv^N4pFMHZYeb|B$peaEI??J{{5vOIz3eIgzVElad0 zbeg1=)N>gwtsPPb_kKYyf7J=5Qp>Q0b%}?1tBAhLHeH+*dQ=_ zU~zTPg2RS&qitdk@9nA7rWjk~$n=ObUO(l>k`^Tbn4L43zp)55buZ1?Ym>P-tID%Z zpaN{yk*ed@Z>TcwK&k?HK*`aZ>fMD{Oi12*914sfZ?rou&^g1!Ma)t)Z@e=}-<;JO z&sl^;yN?dd?jvXt>Afw_v`K3abpxBTE1Wf;H1sUy%TpXq?12S6DD49Paqz51q}sS0 zJ5wlFT?otdSS8`FEy6sjC1J8Z?D?;~fTl-2fL`MMt*P!=nMOH%4sw)h z|Mdmsvphb>U?!_1g7l_ReMfE9f<&#ps|6XQ-8RNty4CK~TTRWsdY-Z))}v83L8iys z7^E>dFozaDt82V}oheikODd?gm7)aG`*sRoIrvZH!%+#>(}Lg?e#8JLV6 zxgIv)WTANMPTFI{Q+U*}LryemQ_GB6;=x42_56D;inK!=Y7gxOaeBOeZvWR8wV$*~ zdm7_8z}qhh&>Y&tqupl_lEk?^WI=qdQ}r`4d;p+lWdGGEE~L_SF@ZyEllGve+$~Bh z+^k#)(uM(NyI}) z+A-cy-w%>Cb#re!$SaLT>!DgR?zgm#78L4Dtpigq0TrSJ*`0c=)=(cRyK0czZM8ba z-fpAXYHkHf9d)POP&%p>6d!8a^+>-_uPRY71xq!hqeO1CU{%@c+&9{araf%!){F;A zqYlCr)L_1$G`IJZZPlo@YAOKMcT_`fLCs|LAmIA?o6R5Xx$C z=oo<9GPde!qxK*4OY~j&^>0ArzH1ZNCWAhe2gkhcI&$~UoxAIIIx$3{z`h{}IDK}B$!EIchqPm8OczV)PdGfc*dpcs*Oa;$h2EnPS% z>R~(v#+mV;JwJGNey}?kT*|)^gY}0u(8}s4f0|nvEuAi37-ddjaj7te3ab!&7G3`H N2`Wu)?+=j9{{!@#dEx*7 literal 0 HcmV?d00001 diff --git a/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-311.pyc b/Задания/task1/Yaroshevskiy/test_site/test_site/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1d616333ee943384d50fec29c8fda6f0cea68943 GIT binary patch literal 521 zcmZutze@u#6i)7PZEZOPCr7C`bZM|4f`~584muQzAZHVLSML|eRcxn@-RvOv2MCI| zI5@cY4>(<+L&@soRuC5_U-|&E{ji_9Y z!bEsy!i0NNVJ7M(K|m4u$%;rX;fiQg6(EB}!bK<_&?l79R}~UYY3wiFfX~Jc4sy%)&ZB~xk-?^P2VlAKV ziY0K-{~=vSV-sUMLaXWDIYR5{e{-Bc)ezw6n?(64P0r2D%#nqxgoM;k1<`g$Q6bCaIKSlF-kncpHzl1q zurV-pLrg`e3j+fS|KW-%A#SR~#1^SyVZzstD!gYuKl}N;?|ZU8%+1+g?GgbbJL8-1etMidx$-GKeQW`om^l&x7GUYv zY)-~U(4OH|3#u~*KkV(+T9f)R?us7m%9LtU+Eqd$O;WjozIJT8sVTlnq(Vh?fOM4N zg`xK{MCvK((Ma;W5buQ8$B_2DR9uE)FG5Z`9WO~j;d@%hxYIH99vhrUrbtC>Afw9w zm9Z%<6zz%-Z&QV62U;iUK4V<^%Hca++>>KYzKj^gY{jXwK<;bFI3}SSL>OzfuX=*n zzlvrzswBVFL+uu4?gWi|arMcgjkQg;)!5o;&dVxF|UN-ZsXtj*vx| z1cD_49mtsZ_4>V9on=Sar|h$tU$ZZ#Z<+SgZjHV0QmF#$t6ec*R}3e-f`*d}{#<)7 zdWnZ=#h{p92I{#n!xAB6XqCy-5DGI7#6G-U=sDD~|HnC4ukG)!@C_ESMJKzvdJ2s* aXk^ehuPkMirPIptS!MZfw$Sv3DgGBSh21Iu literal 0 HcmV?d00001