From 0be63069c7156d1790427d2c298cf8b4cf83e8cb Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Fri, 19 May 2023 22:26:19 +0300
Subject: [PATCH 1/7] Update tgBot(try-exc-finally+usage of func-s in
wwfuncs.py).py
---
...-finally+usage of func-s in wwfuncs.py).py | 21 ++++++++++++++++++-
1 file changed, 20 insertions(+), 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 4b804da..32a5c85 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
@@ -23,6 +23,8 @@ finally:
bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw')
+min_id, max_id = 1, 60
+
@bot.message_handler(commands=["start"])
def start(m, res=False):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
@@ -30,12 +32,14 @@ def start(m, res=False):
item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста")
item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста")
item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных")
+ item5 = types.KeyboardButton("Поиск конкретного предложения по ID")
markup.add(item1)
markup.add(item2)
markup.add(item3)
markup.add(item4)
+ markup.add(item5)
bot.send_message(m.chat.id,
- '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.',
+ '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.\n "Поиск конкретного предложения по ID" - найдите инересующее вас предложение по ID',
reply_markup=markup)
@bot.message_handler(content_types=["text"])
@@ -54,9 +58,24 @@ def handle_text(message):
bot.send_message(message.chat.id, "Предложение дня:\n")
bot.send_message(message.chat.id, a1)
bot.send_photo(message.chat.id, open(i[4], 'rb'))
+ elif (message.text.strip() == "Поиск конкретного предложения по ID"):
+ sent = bot.send_message(message.chat.id,
+ f'Введите идентификатор(ID) от {min_id} до {max_id}, чтобы получить информацию о конкретном предложении: ')
+ bot.register_next_step_handler(sent, ret_id)
else:
bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ")
+def ret_id(message):
+ now_id = int(message.text)
+ if now_id > max_id or now_id < min_id:
+ bot.send_message(message.chat.id, "По такому ID нет данных. Попробуйте заново через 'меню' кнопок найти интересующее вас предложение")
+ return
+ else:
+ z = list(select(now_id))
+ a2 = f'Название: {z[1]};\nЦена: {z[2]};\nСкидка(в процентах): {z[3]};\n'
+ bot.send_message(message.chat.id, a2)
+ bot.send_photo(message.chat.id, open(z[4], 'rb'))
+
bot.polling(none_stop=True, interval=0)
cursor.close()
From 5e11599086463e9022c9f6bf8dc0fd6dc55db36a Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sat, 20 May 2023 10:38:55 +0300
Subject: [PATCH 2/7] 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 | 3 ++-
1 file changed, 2 insertions(+), 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 32a5c85..95f6431 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
@@ -60,7 +60,7 @@ def handle_text(message):
bot.send_photo(message.chat.id, open(i[4], 'rb'))
elif (message.text.strip() == "Поиск конкретного предложения по ID"):
sent = bot.send_message(message.chat.id,
- f'Введите идентификатор(ID) от {min_id} до {max_id}, чтобы получить информацию о конкретном предложении: ')
+ f'Введите идентификатор(ID, целое число) от {min_id} до {max_id}, чтобы получить информацию о конкретном предложении: ')
bot.register_next_step_handler(sent, ret_id)
else:
bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ")
@@ -75,6 +75,7 @@ def ret_id(message):
a2 = f'Название: {z[1]};\nЦена: {z[2]};\nСкидка(в процентах): {z[3]};\n'
bot.send_message(message.chat.id, a2)
bot.send_photo(message.chat.id, open(z[4], 'rb'))
+ bot.send_message(message.chat.id, "Для повторного поиска по ID воспользуйтесь соответствующей кнопкой в 'меню'")
bot.polling(none_stop=True, interval=0)
From 4d08cbf5684bb58829358f9b59d3725fc2540c60 Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <7133210@gmail.com>
Date: Sat, 20 May 2023 16:13:35 +0300
Subject: [PATCH 3/7] PARSBD
---
.idea/22712.iml | 2 +-
.idea/misc.xml | 2 +-
.idea/workspace.xml | 51 +++++++++--------------------
Задания/task1/Sukhanov/DZ_PARSBD.py | 5 ++-
4 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/.idea/22712.iml b/.idea/22712.iml
index 9e6c4ca..aee9ef2 100644
--- a/.idea/22712.iml
+++ b/.idea/22712.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a6fa933..a971a2c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4572841..4d4969c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,11 +5,10 @@
-
-
+
@@ -39,36 +38,26 @@
-<<<<<<< HEAD
- {
- "keyToString": {
- "last_opened_file_path": "C:/Users/Honor/c22712"
- }
-}
-
-=======
-
-
+
+
-
-
-
+
+
+
-
+
@@ -77,7 +66,6 @@
->>>>>>> d1c29f6 (телеграмм бот)
@@ -100,19 +88,19 @@
-
+
-
-
-
+
+
+
-
+
@@ -144,8 +132,8 @@
-
-
+
+
@@ -209,14 +197,7 @@
1680206771744
-
- 1680207517708
-
-
-
- 1680207517708
-
-
+
diff --git a/Задания/task1/Sukhanov/DZ_PARSBD.py b/Задания/task1/Sukhanov/DZ_PARSBD.py
index b472c2a..43ce4fe 100644
--- a/Задания/task1/Sukhanov/DZ_PARSBD.py
+++ b/Задания/task1/Sukhanov/DZ_PARSBD.py
@@ -8,7 +8,7 @@ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres'
cursor = connection.cursor()
cr_qwery = """ create table Parser
- (id serial primary key, name varchar(100), sale varchar(30), price varchar(10), rate varchar(10), picture varchar(100))"""
+ (id serial primary key, name varchar(100), price varchar(10), rate varchar(10), picture varchar(100))"""
#cursor.execute(cr_qwery)
connection.commit()
@@ -20,7 +20,6 @@ html_code = browser.page_source
soup = BeautifulSoup(html_code, 'lxml')
name = soup.find_all('div', class_="product-card__title")
-sale = soup.find_all('div', class_="sc-kYrlTI ciSrDA product-card__badge")
price = soup.find_all('div', class_="price-new")
rate = soup.find_all('div', class_="rating-value")
picture = soup.find_all('div', class_="product-card__image-wrapper")
@@ -29,7 +28,7 @@ for i in range(15):
url = picture[i].find('img').attrs['src']
filename = f"C:\\Users\\71332\PycharmProjects\pythonProject1\\venv\Pictures\{i}.jpg"
wget.download(url, filename)
- ins_qwery = f"""insert into public.Parser(name, sale, price, rate, picture) values ('{name[i].text}', '{sale[i].text}', '{price[i].text}', '{rate[i].text}', '{filename}')"""
+ ins_qwery = f"""insert into public.Parser(name, price, rate, picture) values ('{name[i].text}', '{price[i].text}', '{rate[i].text}', '{filename}')"""
cursor.execute(ins_qwery)
connection.commit()
From 6b05d244786a2edf0c05b97706a4feea86623796 Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <7133210@gmail.com>
Date: Sat, 20 May 2023 16:14:09 +0300
Subject: [PATCH 4/7] =?UTF-8?q?=D0=9E=D0=A8=D0=98=D0=91=D0=9A=D0=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Sukhanov/mistakes.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Задания/task1/Sukhanov/mistakes.py
diff --git a/Задания/task1/Sukhanov/mistakes.py b/Задания/task1/Sukhanov/mistakes.py
new file mode 100644
index 0000000..951569e
--- /dev/null
+++ b/Задания/task1/Sukhanov/mistakes.py
@@ -0,0 +1,28 @@
+import psycopg2
+import wget
+
+from Задания.task1.Sukhanov import DZ_PARSBD
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+cr_qwery = '''create table Parser (id serial primary key, name varchar(100), price varchar(10), rate varchar(10), picture varchar(100))'''
+
+try:
+ cursor.execute(cr_qwery)
+ connection.commit()
+except psycopg2.errors.DuplicateTable:
+ print("duplicate error")
+
+for j in range(15):
+ url = DZ_PARSBD.picture[j].find('img').attrs['src']
+ tempf = f"img\\Parser{j}.jpg"
+ wget.download(url, tempf)
+ try:
+ insert_query = f'''INSERT into public.Parser(name, price, rate, picture) values ('{DZ_PARSBD.name[j].text}', '{DZ_PARSBD.price[j].text}', '{DZ_PARSBD.rate[j].text}', '{tempf}') '''
+ cursor.execute(insert_query)
+ connection.commit()
+ except:
+ connection.rollback()
+
+cursor.close()
+connection.close()
\ No newline at end of file
From f790bf8d96e06296b7510ea3c6659883a1d6e5cb Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 21 May 2023 13:57:21 +0300
Subject: [PATCH 5/7] Update tgBot(try-exc-finally+usage of func-s in
wwfuncs.py).py
---
...(try-exc-finally+usage of func-s in wwfuncs.py).py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 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 95f6431..7a52a21 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
@@ -66,16 +66,17 @@ def handle_text(message):
bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ")
def ret_id(message):
- now_id = int(message.text)
- if now_id > max_id or now_id < min_id:
- bot.send_message(message.chat.id, "По такому ID нет данных. Попробуйте заново через 'меню' кнопок найти интересующее вас предложение")
- return
- else:
+ try:
+ now_id = (message.text)
+ now_id = int(float(now_id))
z = list(select(now_id))
a2 = f'Название: {z[1]};\nЦена: {z[2]};\nСкидка(в процентах): {z[3]};\n'
bot.send_message(message.chat.id, a2)
bot.send_photo(message.chat.id, open(z[4], 'rb'))
bot.send_message(message.chat.id, "Для повторного поиска по ID воспользуйтесь соответствующей кнопкой в 'меню'")
+ except ValueError:
+ bot.send_message(message.chat.id,
+ "По такому ID нет данных. Попробуйте заново через 'меню' кнопок найти интересующее вас предложение")
bot.polling(none_stop=True, interval=0)
From 38162621dd5723c15b561359b79f20b714bab33f Mon Sep 17 00:00:00 2001
From: inweems
Date: Sun, 21 May 2023 15:52:47 +0300
Subject: [PATCH 6/7] =?UTF-8?q?=D0=94=D0=B7=20=D0=BF=D0=B0=D1=80=D1=81?=
=?UTF-8?q?=D0=B8=D0=BD=D0=B3=20=D0=92=D0=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 10 +++----
Задания/task1/Prokhorova/парсинггг.py | 41 +++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 5 deletions(-)
create mode 100644 Задания/task1/Prokhorova/парсинггг.py
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4d4969c..4eca7b1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -38,12 +38,12 @@
- {
+ "keyToString": {
+ "last_opened_file_path": "C:/Users/Honor/c22712",
+ "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
}
-}]]>
+}
diff --git a/Задания/task1/Prokhorova/парсинггг.py b/Задания/task1/Prokhorova/парсинггг.py
new file mode 100644
index 0000000..42e90a9
--- /dev/null
+++ b/Задания/task1/Prokhorova/парсинггг.py
@@ -0,0 +1,41 @@
+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()
+
+create_table = """ create table food
+ (id serial primary key, name varchar(200), price varchar(100), gram varchar(100), stock varchar(100))"""
+
+cursor.execute(create_table)
+connection.commit()
+
+driver = Service('C:\\Users\\Honor\\Desktop\\учеба\\прога\\скачали хроме\chromedriver.exe')
+browser = webdriver.Chrome(service=driver)
+browser.get('https://vkusvill.ru/goods/gotovaya-eda/')
+html_code = browser.page_source
+soup = BeautifulSoup(html_code, 'lxml')
+
+name = soup.find_all('a', class_="ProductCard__link rtext _desktop-md _mobile-sm gray900 js-datalayer-catalog-list-name")
+price = soup.find_all('span', class_="Price Price--md Price--label Price--gray")
+gram = soup.find_all('div', class_="ProductCard__weight rtext _desktop-sm gray500 nobr")
+stock = soup.find_all('div', class_="Rating__text subtitle _desktop-sm gray900")
+
+
+for i in range(15):
+
+
+ ins_qwery = f"""insert into public.food(name, price, gram, stock) values ('{name[i].text}', '{price[i].text}', '{gram[i].text}', '{stock[i].text}')"""
+ cursor.execute(ins_qwery)
+ connection.commit()
+
+
+
+
+cursor.close()
+
+connection.close()
\ No newline at end of file
From 0c2e61994260045cbbb20f3f33c25d3c8052b155 Mon Sep 17 00:00:00 2001
From: inweems
Date: Sun, 21 May 2023 16:03:03 +0300
Subject: [PATCH 7/7] =?UTF-8?q?=D0=94=D0=B7=20=D0=BF=D0=B0=D1=80=D1=81?=
=?UTF-8?q?=D0=B8=D0=BD=D0=B3=20=D0=92=D0=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/22712.iml | 2 +-
.idea/misc.xml | 2 +-
.idea/workspace.xml | 55 +++++++++++++++----
.../Prokhorova/{парсинггг.py => parsing.py} | 0
4 files changed, 47 insertions(+), 12 deletions(-)
rename Задания/task1/Prokhorova/{парсинггг.py => parsing.py} (100%)
diff --git a/.idea/22712.iml b/.idea/22712.iml
index aee9ef2..7eb1baf 100644
--- a/.idea/22712.iml
+++ b/.idea/22712.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a971a2c..d56657a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4eca7b1..d30f954 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,11 @@
-
+
-
+
@@ -38,13 +38,18 @@
- {
- "keyToString": {
- "last_opened_file_path": "C:/Users/Honor/c22712",
- "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
+
-
+}]]>
+
+
+
+
+
+
@@ -66,6 +71,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -132,6 +158,7 @@
+
@@ -197,7 +224,14 @@
1680206771744
-
+
+ 1684673567872
+
+
+
+ 1684673567872
+
+
@@ -218,7 +252,8 @@
-
+
+
diff --git a/Задания/task1/Prokhorova/парсинггг.py b/Задания/task1/Prokhorova/parsing.py
similarity index 100%
rename from Задания/task1/Prokhorova/парсинггг.py
rename to Задания/task1/Prokhorova/parsing.py