diff --git a/.idea/22712.iml b/.idea/22712.iml
index 74d515a..9e6c4ca 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..a6fa933 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]/shelved.patch
new file mode 100644
index 0000000..09a0bb9
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]/shelved.patch
@@ -0,0 +1,126 @@
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1675926797018 \r\n \r\n \r\n 1675926797018 \r\n \r\n \r\n \r\n 1675927078342 \r\n \r\n \r\n \r\n 1675927078342 \r\n \r\n \r\n 1675931967836 \r\n \r\n \r\n \r\n 1675931967836 \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n file://$PROJECT_DIR$/main.py \r\n 8 \r\n \r\n \r\n \r\n \r\n \r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/workspace.xml b/.idea/workspace.xml
+--- a/.idea/workspace.xml
++++ b/.idea/workspace.xml
+@@ -4,7 +4,7 @@
+
+
+
+-
++
+
+
+
+@@ -35,31 +35,54 @@
+
+
+
+- {
++ "keyToString": {
++ "RunOnceActivity.OpenProjectViewOnStart": "true",
++ "RunOnceActivity.ShowReadmeOnStart": "true",
++ "WebServerToolWindowFactoryState": "false",
++ "last_opened_file_path": "C:/Users/gusev/OneDrive/Рабочий стол/Уроки Pyton/Урок №1/c22712",
++ "settings.editor.selected.configurable": "vcs.Git"
+ }
+-}]]>
++}
+
+-
++
+
+
+
+
+
+
+-
++
++
+
+-
++
+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
+
+
+@@ -92,7 +115,14 @@
+
+ 1675931967836
+
+-
++
++ 1676412025886
++
++
++
++ 1676412025886
++
++
+
+
+
+@@ -103,7 +133,13 @@
+
+
+
+-
++
++
++
++
++
++
++
+
+
+
+@@ -111,7 +147,8 @@
+
+
+
+-
++
++
+
+
+
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]1/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]1/shelved.patch
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03__Changes_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03__Changes_.xml
new file mode 100644
index 0000000..75143a3
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 28f4cba..4572841 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,12 @@
-
+
+
+
+
+
@@ -20,7 +24,7 @@
-
+
@@ -35,12 +39,45 @@
+<<<<<<< HEAD
+ {
+ "keyToString": {
+ "last_opened_file_path": "C:/Users/Honor/c22712"
+ }
+}
+
+=======
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> d1c29f6 (телеграмм бот)
@@ -63,6 +100,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -86,6 +144,8 @@
+
+
@@ -142,7 +202,21 @@
1679839777822
-
+
+ 1680206771744
+
+
+
+ 1680206771744
+
+
+ 1680207517708
+
+
+
+ 1680207517708
+
+
@@ -162,14 +236,15 @@
-
+
+
file://$PROJECT_DIR$/main.py
- 8
+ 5
diff --git a/fars.py b/fars.py
new file mode 100644
index 0000000..7740187
--- /dev/null
+++ b/fars.py
@@ -0,0 +1,44 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+from time import sleep
+import psycopg2
+s = Service("C:\Driver\chromedriver.exe")
+browser = webdriver.Chrome(service=s)
+browser.get("https://drivenew.ru/layfkhaki/besplatno/top-10-vinodelcheskikh-khozyaystv-krasnodarskogo-kraya/")
+sleep(1)
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, "lxml")
+name = soup.find_all("h2")
+contacts = soup.find_all("div", class_="article-info")
+
+address = []
+number = []
+for element in contacts:
+ a = element.find_all("p")[1]
+ n = element.find_all("p")[2]
+ address.append(a)
+ number.append(n)
+
+pic = soup.find("div", class_="white-bg white-bg-text box-15-new").find_all("img")
+picture = []
+url = "https://drivenew.ru"
+for i in pic:
+ p = url + i.attrs.get("src")
+ picture.append(p)
+
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+cursor = connection.cursor()
+create = """create table Distilleries
+ (id serial primary key , Name varchar(100), Place varchar(200), Contacts varchar(100), ImageLink varchar(80));"""
+cursor.execute(create)
+connection.commit()
+for j in range(10):
+ qwery = f"insert into public.distilleries(Name, Place, Contacts, ImageLink) values('{name[j].text.strip()}', '{address[j].text.strip()}', '{number[j].text.strip()}', '{picture[j]}')"
+ cursor.execute(qwery)
+ connection.commit()
+cursor.execute('select * from Distilleries')
+print(cursor.fetchall())
+cursor.close()
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Antipenko/link_to_gh b/Задания/task1/Antipenko/link_to_gh
new file mode 100644
index 0000000..457aba9
--- /dev/null
+++ b/Задания/task1/Antipenko/link_to_gh
@@ -0,0 +1 @@
+https://github.com/ada-dmitry/PyProg_ada/tree/master/Python/TeleBot
diff --git a/Задания/task1/Filcheva/bd.py b/Задания/task1/Filcheva/bd.py
new file mode 100644
index 0000000..edf9e9c
--- /dev/null
+++ b/Задания/task1/Filcheva/bd.py
@@ -0,0 +1,44 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+from time import sleep
+import psycopg2
+s = Service("C:\Driver\chromedriver.exe")
+browser = webdriver.Chrome(service=s)
+browser.get("https://drivenew.ru/layfkhaki/besplatno/top-10-vinodelcheskikh-khozyaystv-krasnodarskogo-kraya/")
+sleep(1)
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, "lxml")
+name = soup.find_all("h2")
+contacts = soup.find_all("div", class_="article-info")
+
+address = []
+number = []
+for element in contacts:
+ a = element.find_all("p")[1]
+ n = element.find_all("p")[2]
+ address.append(a)
+ number.append(n)
+
+pic = soup.find("div", class_="white-bg white-bg-text box-15-new").find_all("img")
+picture = []
+url = "https://drivenew.ru"
+for i in pic:
+ p = url + i.attrs.get("src")
+ picture.append(p)
+
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+cursor = connection.cursor()
+create = """create table Distilleries
+ (id serial primary key , Name varchar(100), Place varchar(200), Contacts varchar(100), ImageLink varchar(80));"""
+cursor.execute(create)
+connection.commit()
+for j in range(10):
+ qwery = f"insert into public.distilleries(Name, Place, Contacts, ImageLink) values('{name[j].text.strip()}', '{address[j].text.strip()}', '{number[j].text.strip()}', '{picture[j]}')"
+ cursor.execute(qwery)
+ connection.commit()
+cursor.execute('select * from Distilleries')
+print(cursor.fetchall())
+cursor.close()
+connection.close()
diff --git a/Задания/task1/Filcheva/bot.py b/Задания/task1/Filcheva/bot.py
new file mode 100644
index 0000000..7e700c6
--- /dev/null
+++ b/Задания/task1/Filcheva/bot.py
@@ -0,0 +1,37 @@
+import telebot
+import psycopg2
+from telebot import types
+# Создаем экземпляр бота
+bot = telebot.TeleBot('5898574743:AAF2y_y3U2IfWwQVJ_lF6mmiDPlx1YgU9-Q')
+# Функция, обрабатывающая команду /start
+
+@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()
+ m = int(n)
+ 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 = {m}")
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+
+bot.polling()
diff --git a/Задания/task1/Filcheva/bot1.py b/Задания/task1/Filcheva/bot1.py
new file mode 100644
index 0000000..7265303
--- /dev/null
+++ b/Задания/task1/Filcheva/bot1.py
@@ -0,0 +1,121 @@
+import telebot
+import psycopg2
+from telebot import types
+# Создаем экземпляр бота
+bot = telebot.TeleBot('5898574743:AAF2y_y3U2IfWwQVJ_lF6mmiDPlx1YgU9-Q')
+# Функция, обрабатывающая команду /start
+
+@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()
+ m = int(n)
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+ cursor = connection.cursor()
+
+ if (m==1):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(1)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 2):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(2)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 3):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(3)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 4):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(4)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 5):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(5)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 6):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(6)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 7):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(7)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 8):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(8)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 9):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(9)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 10):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(10)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+
+bot.polling()
diff --git a/Задания/task1/Gasanova/laba b/Задания/task1/Gasanova/laba
deleted file mode 100644
index 980a0d5..0000000
--- a/Задания/task1/Gasanova/laba
+++ /dev/null
@@ -1 +0,0 @@
-Hello World!
diff --git a/Задания/task1/Gasanova/parser.py b/Задания/task1/Gasanova/parser.py
deleted file mode 100644
index 1252676..0000000
--- a/Задания/task1/Gasanova/parser.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Diana Gasanova
-import requests
-from bs4 import BeautifulSoup as bs
-URL = "https://www.kinopoisk.ru/lists/movies/top-250-2020/"
-r = requests.get(URL, timeout=10)
-soup = bs(r.text, "html.parser")
-films = soup.find_all(attrs={"class": "styles_mainTitle__IFQyZ styles_activeMovieTittle__kJdJj"})
-for film in films:
- print(film.text)
diff --git a/Задания/task1/Gasanova/penny.py b/Задания/task1/Gasanova/penny.py
new file mode 100644
index 0000000..686e539
--- /dev/null
+++ b/Задания/task1/Gasanova/penny.py
@@ -0,0 +1,29 @@
+# парсер к полусему 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()
diff --git a/Задания/task1/Gusev/.idea/.gitignore b/Задания/task1/Gusev/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Задания/task1/Gusev/.idea/Gusev.iml b/Задания/task1/Gusev/.idea/Gusev.iml
new file mode 100644
index 0000000..d0876a7
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/Gusev.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Задания/task1/Gusev/.idea/inspectionProfiles/profiles_settings.xml b/Задания/task1/Gusev/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Задания/task1/Gusev/.idea/misc.xml b/Задания/task1/Gusev/.idea/misc.xml
new file mode 100644
index 0000000..a971a2c
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Задания/task1/Gusev/.idea/modules.xml b/Задания/task1/Gusev/.idea/modules.xml
new file mode 100644
index 0000000..e3f948d
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Задания/task1/Gusev/.idea/vcs.xml b/Задания/task1/Gusev/.idea/vcs.xml
new file mode 100644
index 0000000..c2365ab
--- /dev/null
+++ b/Задания/task1/Gusev/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Задания/task1/Gusev/First code.py b/Задания/task1/Gusev/First code.py
index bc4200d..e69de29 100644
--- a/Задания/task1/Gusev/First code.py
+++ b/Задания/task1/Gusev/First code.py
@@ -1 +0,0 @@
-print('Hello, World!')
\ No newline at end of file
diff --git a/Задания/task1/Gusev/Parcing and working with BD.py b/Задания/task1/Gusev/Parcing and working with BD.py
new file mode 100644
index 0000000..90f012d
--- /dev/null
+++ b/Задания/task1/Gusev/Parcing and working with BD.py
@@ -0,0 +1,56 @@
+from bs4 import BeautifulSoup # подключение к библиотекам парсинга и работы с базами данных
+import psycopg2
+from wget import download
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+
+S = Service("D:\Драйвер\chromedriver.exe")
+browser = webdriver.Chrome(service=S)
+browser.get('https://ultrasport.ru/catalog/velosipedy/gornye_velosipedy/') # подключение к сайту, с которого будем парсить данные
+html_text = browser.page_source # сохранение html кода страницы в переменную html_text
+soup = BeautifulSoup(html_text, 'lxml') # преобразуем код в дерево объектов
+
+info = soup.find_all('div', class_="inner_wrap TYPE_1") # поиск всех описывающих товар общих тэгов
+
+try:
+ connection = psycopg2.connect( # подключение к базе данных
+ host='localhost',
+ dbname='Bicycles',
+ user='postgres',
+ password='Q1w2e3r4'
+ )
+ connection.autocommit = True # настройка автоматического комита
+
+ with connection.cursor() as cursor: # создание таблицы в базе данных
+ cursor.execute(
+ """CREATE TABLE bikes(
+ id serial PRIMARY KEY,
+ bike_name varchar(100) NOT NULL,
+ bike_view varchar(1000) NOT NULL,
+ bike_price varchar(100) NOT NULL,
+ bike_availability varchar(100) NOT NULL);
+ """
+ )
+ with connection.cursor() as cursor: # заполнение таблицы данным, которые мы спарсили с сайта
+ for i, item in enumerate(info):
+ name = item.find('a', class_="dark_link js-notice-block__title option-font-bold font_sm").text.strip()
+ price = item.find('div', class_="price only_price font-bold font_mxs").text.strip()
+ enough = item.find('span', class_="value font_sxs").text.strip()
+ p_src = item.find('img', class_="lazy img-responsive").get("src")
+ download(p_src, f"images/{i+1}.jpg")
+ cursor.execute(
+ f"""INSERT INTO public.bikes(
+ bike_name, bike_view, bike_price, bike_availability)
+ VALUES
+ ('{name}','images/{i+1}.jpg','{price}','{enough}');"""
+ )
+
+
+except Exception as _ex: # обработка ошибок
+ print("[INFO] ERROR", _ex)
+
+finally: # завершение подключения
+ if connection:
+ connection.close()
+ print("[INFO] Connection closed")
+
diff --git a/Задания/task1/Gusev/images/1.jpg b/Задания/task1/Gusev/images/1.jpg
new file mode 100644
index 0000000..69b1b38
Binary files /dev/null and b/Задания/task1/Gusev/images/1.jpg differ
diff --git a/Задания/task1/Gusev/images/10.jpg b/Задания/task1/Gusev/images/10.jpg
new file mode 100644
index 0000000..6f9d479
Binary files /dev/null and b/Задания/task1/Gusev/images/10.jpg differ
diff --git a/Задания/task1/Gusev/images/11.jpg b/Задания/task1/Gusev/images/11.jpg
new file mode 100644
index 0000000..9bd8595
Binary files /dev/null and b/Задания/task1/Gusev/images/11.jpg differ
diff --git a/Задания/task1/Gusev/images/12.jpg b/Задания/task1/Gusev/images/12.jpg
new file mode 100644
index 0000000..5b027bf
Binary files /dev/null and b/Задания/task1/Gusev/images/12.jpg differ
diff --git a/Задания/task1/Gusev/images/13.jpg b/Задания/task1/Gusev/images/13.jpg
new file mode 100644
index 0000000..39b2dc7
Binary files /dev/null and b/Задания/task1/Gusev/images/13.jpg differ
diff --git a/Задания/task1/Gusev/images/14.jpg b/Задания/task1/Gusev/images/14.jpg
new file mode 100644
index 0000000..cde49a6
Binary files /dev/null and b/Задания/task1/Gusev/images/14.jpg differ
diff --git a/Задания/task1/Gusev/images/15.jpg b/Задания/task1/Gusev/images/15.jpg
new file mode 100644
index 0000000..47c1fe2
Binary files /dev/null and b/Задания/task1/Gusev/images/15.jpg differ
diff --git a/Задания/task1/Gusev/images/16.jpg b/Задания/task1/Gusev/images/16.jpg
new file mode 100644
index 0000000..c5822ef
Binary files /dev/null and b/Задания/task1/Gusev/images/16.jpg differ
diff --git a/Задания/task1/Gusev/images/17.jpg b/Задания/task1/Gusev/images/17.jpg
new file mode 100644
index 0000000..aa92286
Binary files /dev/null and b/Задания/task1/Gusev/images/17.jpg differ
diff --git a/Задания/task1/Gusev/images/18.jpg b/Задания/task1/Gusev/images/18.jpg
new file mode 100644
index 0000000..25ea7d0
Binary files /dev/null and b/Задания/task1/Gusev/images/18.jpg differ
diff --git a/Задания/task1/Gusev/images/19.jpg b/Задания/task1/Gusev/images/19.jpg
new file mode 100644
index 0000000..4e613e1
Binary files /dev/null and b/Задания/task1/Gusev/images/19.jpg differ
diff --git a/Задания/task1/Gusev/images/2.jpg b/Задания/task1/Gusev/images/2.jpg
new file mode 100644
index 0000000..dc4217e
Binary files /dev/null and b/Задания/task1/Gusev/images/2.jpg differ
diff --git a/Задания/task1/Gusev/images/20.jpg b/Задания/task1/Gusev/images/20.jpg
new file mode 100644
index 0000000..4189e98
Binary files /dev/null and b/Задания/task1/Gusev/images/20.jpg differ
diff --git a/Задания/task1/Gusev/images/21.jpg b/Задания/task1/Gusev/images/21.jpg
new file mode 100644
index 0000000..5b1c01f
Binary files /dev/null and b/Задания/task1/Gusev/images/21.jpg differ
diff --git a/Задания/task1/Gusev/images/22.jpg b/Задания/task1/Gusev/images/22.jpg
new file mode 100644
index 0000000..8efeb78
Binary files /dev/null and b/Задания/task1/Gusev/images/22.jpg differ
diff --git a/Задания/task1/Gusev/images/23.jpg b/Задания/task1/Gusev/images/23.jpg
new file mode 100644
index 0000000..ac9c616
Binary files /dev/null and b/Задания/task1/Gusev/images/23.jpg differ
diff --git a/Задания/task1/Gusev/images/24.jpg b/Задания/task1/Gusev/images/24.jpg
new file mode 100644
index 0000000..2837150
Binary files /dev/null and b/Задания/task1/Gusev/images/24.jpg differ
diff --git a/Задания/task1/Gusev/images/3.jpg b/Задания/task1/Gusev/images/3.jpg
new file mode 100644
index 0000000..b4c14cb
Binary files /dev/null and b/Задания/task1/Gusev/images/3.jpg differ
diff --git a/Задания/task1/Gusev/images/4.jpg b/Задания/task1/Gusev/images/4.jpg
new file mode 100644
index 0000000..d64bab0
Binary files /dev/null and b/Задания/task1/Gusev/images/4.jpg differ
diff --git a/Задания/task1/Gusev/images/5.jpg b/Задания/task1/Gusev/images/5.jpg
new file mode 100644
index 0000000..c80e0cc
Binary files /dev/null and b/Задания/task1/Gusev/images/5.jpg differ
diff --git a/Задания/task1/Gusev/images/6.jpg b/Задания/task1/Gusev/images/6.jpg
new file mode 100644
index 0000000..91fc809
Binary files /dev/null and b/Задания/task1/Gusev/images/6.jpg differ
diff --git a/Задания/task1/Gusev/images/7.jpg b/Задания/task1/Gusev/images/7.jpg
new file mode 100644
index 0000000..f360f23
Binary files /dev/null and b/Задания/task1/Gusev/images/7.jpg differ
diff --git a/Задания/task1/Gusev/images/8.jpg b/Задания/task1/Gusev/images/8.jpg
new file mode 100644
index 0000000..34b4fbd
Binary files /dev/null and b/Задания/task1/Gusev/images/8.jpg differ
diff --git a/Задания/task1/Gusev/images/9.jpg b/Задания/task1/Gusev/images/9.jpg
new file mode 100644
index 0000000..387e7af
Binary files /dev/null and b/Задания/task1/Gusev/images/9.jpg differ
diff --git a/Задания/task1/Gusev/parsing.py b/Задания/task1/Gusev/parsing.py
new file mode 100644
index 0000000..e45c163
--- /dev/null
+++ b/Задания/task1/Gusev/parsing.py
@@ -0,0 +1,61 @@
+from bs4 import BeautifulSoup # подключение к библиотекам парсинга и работы с базами данных
+import psycopg2
+from wget import download
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+
+S = Service("D:\Драйвер\chromedriver.exe")
+browser = webdriver.Chrome(service=S)
+browser.get('https://ultrasport.ru/catalog/velosipedy/gornye_velosipedy/') # подключение к сайту, с которого будем парсить данные
+html_text = browser.page_source # сохранение html кода страницы в переменную html_text
+soup = BeautifulSoup(html_text, 'lxml') # преобразуем код в дерево объектов
+
+info = soup.find_all('div', class_="inner_wrap TYPE_1") # поиск всех описывающих товар общих тэгов
+
+try:
+ connection = psycopg2.connect( # подключение к базе данных
+ host='localhost',
+ dbname='Bicycles',
+ user='postgres',
+ password='Q1w2e3r4'
+ )
+ connection.autocommit = True # настройка автоматического комита
+
+ with connection.cursor() as cursor: # создание таблицы в базе данных
+ cursor.execute(
+ """CREATE TABLE bikes(
+ id serial PRIMARY KEY,
+ bike_name varchar(100) NOT NULL,
+ bike_view varchar(1000) NOT NULL,
+ bike_price varchar(100) NOT NULL,
+ bike_availability varchar(100) NOT NULL);
+ """
+ )
+ with connection.cursor() as cursor: # заполнение таблицы данным, которые мы спарсили с сайта
+ for i, item in enumerate(info):
+ name = item.find('a', class_="dark_link js-notice-block__title option-font-bold font_sm").text.strip()
+ price = item.find('div', class_="price only_price font-bold font_mxs").text.strip()
+ enough = item.find('span', class_="value font_sxs").text.strip()
+ p_src = item.find('img', class_="lazy img-responsive").get("src")
+ download(p_src, f"images/{i+1}.jpg")
+ cursor.execute(
+ f"""INSERT INTO public.bikes(
+ bike_name, bike_view, bike_price, bike_availability)
+ VALUES
+ ('{name}','images/{i+1}.jpg','{price}','{enough}');"""
+ )
+
+
+except Exception as _ex: # обработка ошибок
+ print("[INFO] ERROR", _ex)
+
+finally: # завершение подключения
+ if connection:
+ connection.close()
+ print("[INFO] Connection closed")
+
+
+
+
+
+
diff --git a/Задания/task1/Gusev/Задание b/Задания/task1/Gusev/Задание
new file mode 100644
index 0000000..6053eab
--- /dev/null
+++ b/Задания/task1/Gusev/Задание
@@ -0,0 +1 @@
+Проверка работы.
\ No newline at end of file
diff --git a/Задания/task1/Kulikov/db_taskpostgres.py b/Задания/task1/Kulikov/db_taskpostgres.py
new file mode 100644
index 0000000..51c9936
--- /dev/null
+++ b/Задания/task1/Kulikov/db_taskpostgres.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:\data\hrome\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:\Users\kingo\PycharmProjects\pythonProject2\TOP' + str(i) + '.jpeg'
+ qwery=f"""UPDATE public.music
+ SET Картинки='{puti}'
+ WHERE id={i}"""
+ cursor.execute(qwery)
+ connection.commit()
\ No newline at end of file
diff --git a/Задания/task1/Kuranova/parsing пивоварни.py b/Задания/task1/Kuranova/parsing пивоварни.py
new file mode 100644
index 0000000..be62108
--- /dev/null
+++ b/Задания/task1/Kuranova/parsing пивоварни.py
@@ -0,0 +1,43 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+import psycopg2
+from time import sleep
+s = Service("C:\data\chromedriver.exe")
+browser = webdriver.Chrome(service=s)
+browser.get('https://untappd.com/brewery/top_rated')
+sleep(1)
+html_text=browser.page_source
+soup = BeautifulSoup(html_text, 'lxml')
+ratings = soup.find_all('div', class_='beer-item')
+item = []
+for i in ratings:
+ c = i.text
+ c = c.split('\n')
+ for k in c:
+ if k == '':
+ c.pop(c.index(k))
+ d = i.find('img').get('src')
+ c.append(d)
+ item.append(c)
+item.pop(3)
+item.pop(8)
+
+
+connection = psycopg2.connect(host='localhost', dbname='breweries', user='postgres', password='Q1w2e3r4t5')
+cursor=connection.cursor()
+create = """ create table Information
+ (id int primary key, Name varchar(100), Place varchar(150), Sorts varchar(15), AmountOfRatings varchar(25),
+ Rating varchar(10), ImageLink varchar(150));"""
+cursor.execute(create)
+connection.commit()
+for i in range(20):
+ insert_qwery="""INSERT INTO public.Information(id,Name, Place, Sorts, AmountOfRatings, Rating, ImageLink) VALUES
+ ( '"""+str(i+1)+"""', '"""+item[i][0]+"""', '"""+item[i][1]+"""', '"""+item[i][2]+"""', '"""+item[i][3]+"""',
+ '"""+item[i][9]+"""', '"""+item[i][13]+"""');""";
+ cursor.execute(insert_qwery)
+ connection.commit()
+cursor.execute('select * from Information')
+print(cursor.fetchall())
+cursor.close()
+connection.close()
diff --git a/Задания/task1/Kuznetsov/db.py b/Задания/task1/Kuznetsov/db.py
new file mode 100644
index 0000000..78b4918
--- /dev/null
+++ b/Задания/task1/Kuznetsov/db.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()
+
+creat_qwery = """ create table Parsing
+ (id serial primary key, product_name varchar(100), description varchar(1000), price varchar(10), priceDis varchar(30), scr varchar(100))"""
+
+cursor.execute(creat_qwery)
+connection.commit()
+
+s = Service('E:\\Downloads\\chromedriver_win32.zip\\chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://trial-sport.ru/gds.php?s=51516&c1=1070639&c2=1070640')
+html_code = browser.page_source
+soup = BeautifulSoup(html_code, 'lxml')
+product_name=soup.find_all('a', class_='title')
+description=soup.find_all('span', class_='description')
+price = soup.find_all('span', class_="price")
+priceDis = soup.find_all('span', class_="discount")
+picture = soup.find_all('div', class_="img")
+
+
+for i in range(20):
+ url = 'https://trial-sport.ru/gds.php?s=51516&c1=1070639&c2=1070640'+picture[i].find('a').find('img')['src']
+ filename = f"E:\Downloads\parcing\img\{i}.jpg"
+ wget.download(url, filename)
+ cursor.execute(f"""insert into Parsing (product_name, description, price, priceDis, scr)
+ VALUES ('{product_name[i].text}','{description[i].text}', '{price[i].text}', '{priceDis[i].text}', '{filename}')""")
+ connection.commit()
+
+
+
+cursor.close()
+
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Kuznetsov/parcing.py b/Задания/task1/Kuznetsov/parcing.py
index 0227481..bd717c3 100644
--- a/Задания/task1/Kuznetsov/parcing.py
+++ b/Задания/task1/Kuznetsov/parcing.py
@@ -12,4 +12,3 @@ product_name=soup.find_all('a', class_='title')
description=soup.find_all('span', class_='description')
for product_name, description in zip(product_name, description):
print(f"Продукт: {product_name.text} \nОписание: {description.text}")
-print(" ")
diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py
index cfa0920..fe8a029 100644
--- a/Задания/task1/Lahin/postgres.py
+++ b/Задания/task1/Lahin/postgres.py
@@ -4,6 +4,7 @@ from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
+import config
i = 1
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
browser = webdriver.Chrome(service=s)
@@ -22,14 +23,14 @@ productst = soup.find_all('a', class_="product-title__text")
pricest = soup.find_all('span', class_="price__main-value")
features = soup.find_all('span', class_="product-feature-list__value")
pictures = soup.find_all('div', class_="product-picture-container")
-connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+connection=psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password)
cursor = connection.cursor()
-""" insert = CREATE TABLE public.laptops(
+insert = """CREATE TABLE public.laptops(
id serial primary key,
-product varchar(100),
-price varchar(15),
-diagonal varchar(5),
-resolution varchar(20),
+Product varchar(100),
+Price varchar(15),
+Diagonal varchar(5),
+Resolution varchar(20),
CPU varchar(50),
RAM varchar(15),
Graphics_Controller varchar(40),
@@ -37,7 +38,7 @@ Volume varchar(25),
src varchar(100)
);
"""
-insert = """TRUNCATE TABLE public.laptops; ALTER SEQUENCE laptops_id_seq RESTART WITH 1;"""
+
cursor.execute(insert)
connection.commit()
for i in range(len(productst)):
@@ -49,13 +50,11 @@ for i in range(len(productst)):
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)
+ 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()
-cursor.execute("select * from laptops")
-print("Результат", cursor.fetchall())
cursor.close()
-connection.close()
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py
new file mode 100644
index 0000000..3031c38
--- /dev/null
+++ b/Задания/task1/Lahin/telegrambot.py
@@ -0,0 +1,38 @@
+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)
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')
+
+@bot.message_handler(content_types=["text"])
+def from_bd(message):
+ try:
+ current_id = int(message.text)
+ except BaseException:
+ bot.send_message(message.chat.id, "Вы неправильно ввели ID. Попробуйте снова:")
+ return
+ if current_id > max_id:
+ 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))
+ bot.send_message(message.chat.id, f"Введите следующий ID от 1 до {max_id}:")
+bot.polling(none_stop=True, interval=0)
+
+
diff --git a/Задания/task1/Prokhorova/dz.py b/Задания/task1/Prokhorova/dz.py
new file mode 100644
index 0000000..2dfcb87
--- /dev/null
+++ b/Задания/task1/Prokhorova/dz.py
@@ -0,0 +1,49 @@
+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 dresses
+ (id serial primary key, name varchar(200), sale varchar(50), price varchar(50), info varchar(50), picture varchar(200))"""
+
+cursor.execute(create_table)
+connection.commit()
+
+driver = Service('D:\data\chromedriver.exe')
+browser = webdriver.Chrome(service=driver)
+browser.get('https://www.ozon.ru/category/platya-zhenskie-7502/')
+html_code = browser.page_source
+soup = BeautifulSoup(html_code, 'lxml')
+
+names = []
+sale = soup.find_all('div', class_="eg1 g3e")
+
+price = soup.find_all('span', class_="a2a-a2")
+info = soup.find_all('span', class_="je4")
+picture = soup.find_all('div', class_="k1m")
+
+products = soup.find_all("div", class_="k7o o7k")
+for product in products:
+ names.append(soup.find('span', class_="m2e e3m m3e m5e tsBodyL k7l l7k").text.strip())
+
+print(names)
+exit(0)
+
+for i in range(20):
+ url = picture[i].find('img').attrs['src']
+ file_name = f"C:\\Users\\Honor\\Desktop\\учеба\\прога\\pictures\\{i}.jpg"
+ wget.download(url, file_name)
+ ins_table = f"""insert into public.dresses(name, sale, price, info, picture) values ('{name[i].text}', '{sale[i].text}', '{price[i].text}', '{info[i].text}', '{file_name}')"""
+ cursor.execute(ins_table)
+ connection.commit()
+
+
+
+
+cursor.close()
+
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Prokhorova/pars.py b/Задания/task1/Prokhorova/pars.py
new file mode 100644
index 0000000..6732d15
--- /dev/null
+++ b/Задания/task1/Prokhorova/pars.py
@@ -0,0 +1,15 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+
+s = Service('D:\data\chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://www.kfc.ru/')
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, 'lxml')
+
+prices = soup.find_all(attrs={"class": "GFmMCzZoYv"})
+titles = soup.find_all(attrs={"class": "_14ZQf5wtqx c-description"})
+
+for price, title in zip(prices, titles):
+ print(f" название {title.text} ; цена: {price.text}")
\ No newline at end of file
diff --git a/Задания/task1/Prokhorova/tgbot.py b/Задания/task1/Prokhorova/tgbot.py
new file mode 100644
index 0000000..6c10419
--- /dev/null
+++ b/Задания/task1/Prokhorova/tgbot.py
@@ -0,0 +1,37 @@
+import telebot
+import random
+from telebot import types
+
+f = open('C:\\Users\\Honor\\Desktop\\учеба\\прога\\тг_бот\\бот\\факт.txt', 'r', encoding='UTF-8')
+facts = f.read().split('\n')
+f.close()
+
+f = open('C:\\Users\\Honor\\Desktop\\учеба\\прога\\тг_бот\\бот\\поговорка.txt', 'r', encoding='UTF-8')
+thinks = f.read().split('\n')
+f.close()
+
+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Факт'
+ ' для получения интересного факта\nПоговорка '
+ '— для получения мудрой цитаты ', reply_markup=markup)
+
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if message.text.strip() == 'Факт' :
+ answer = random.choice(facts)
+
+ elif message.text.strip() == 'Поговорка':
+ answer = random.choice(thinks)
+
+ bot.send_message(message.chat.id, answer)
+
+bot.polling(none_stop=True, interval=0)
\ No newline at end of file
diff --git a/Задания/task1/Samigullin/bd.py b/Задания/task1/Samigullin/bd.py
new file mode 100644
index 0000000..447afcc
--- /dev/null
+++ b/Задания/task1/Samigullin/bd.py
@@ -0,0 +1,43 @@
+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
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+
+
+
+s = Service('C:/Users/rusta/OneDrive/Рабочий стол/ИНФА/инфа 2 сем/driver/chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://www.kp.ru/expert/elektronika/luchshie-noutbuki/')
+time.sleep (10)
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, 'lxml')
+
+creat_table="""create table notes
+ (id serial primary key, name varchar(150),
+ scr varchar(150))"""
+cursor.execute(creat_table)
+connection.commit()
+
+
+names= soup.find_all('h3', class_="wp-block-heading")
+pictures = soup.find_all('figure', class_="wp-block-image size-full")
+print(len(names))
+for i in range(len(names)):
+ url = pictures[i].find('img')['src']
+ filename = f"C:\\Users\\rusta\\OneDrive\\Рабочий стол\\pictures\\{i}.jpg"
+ wget.download(url, filename)
+
+ insert_qwery = """INSERT INTO public.notes(name, scr)
+ VALUES( %s, %s, %s);"""
+ record_to_insert = (names[i].text, filename)
+ cursor.execute(insert_qwery, record_to_insert)
+ connection.commit()
+
+cursor.close()
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Samigullin/test1.py b/Задания/task1/Samigullin/test1.py
new file mode 100644
index 0000000..c834943
--- /dev/null
+++ b/Задания/task1/Samigullin/test1.py
@@ -0,0 +1,15 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+import time
+
+s = Service('C:/Users/rusta/OneDrive/Рабочий стол/ИНФА/инфа 2 сем/driver/chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://lafoy.ru/modnye-muzhskie-strizhki-2023-3052/')
+time.sleep (10)
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, 'lxml')
+haircuts = soup.find_all('h2', class_='tm8 post__title')
+
+for i in range(0, 30):
+ print(haircuts[i].text)
diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Задания/task1/Sukhanov/BOT_TG.py
@@ -0,0 +1 @@
+
diff --git a/Задания/task1/Uskova/DataBaze.py b/Задания/task1/Uskova/DataBaze.py
new file mode 100644
index 0000000..bdd3ded
--- /dev/null
+++ b/Задания/task1/Uskova/DataBaze.py
@@ -0,0 +1,39 @@
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+import psycopg2
+import wget
+
+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)
+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')
+
+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.close()
+connection.close()
diff --git a/Задания/task1/Uskova/bott.py b/Задания/task1/Uskova/bott.py
new file mode 100644
index 0000000..47436e0
--- /dev/null
+++ b/Задания/task1/Uskova/bott.py
@@ -0,0 +1,36 @@
+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')
+cursor = connection.cursor()
+
+ins_query = """SELECT * FROM public.Notebooks"""
+cursor.execute(ins_query)
+array = list(cursor.fetchall())
+
+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)
+@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)
+bot.polling(none_stop=True, interval=0)
diff --git a/Задания/task1/Yaroshevskiy/main.py b/Задания/task1/Yaroshevskiy/main.py
index 11eea2c..bb2eb6d 100644
--- a/Задания/task1/Yaroshevskiy/main.py
+++ b/Задания/task1/Yaroshevskiy/main.py
@@ -1,6 +1,5 @@
from bs4 import BeautifulSoup
from selenium import webdriver
-from selenium.webdriver.chrome.service import Service
from wget import download
import psycopg2 as psyc
@@ -27,5 +26,4 @@ with psyc.connect(dbname="db_for_parse", user="perfecto") as conn:
cursor.execute(f"""insert into images(link, name, price, description, file)
values ('{image}', '{title}', '{price}', '{desc}', 'images/{i}.jpg')""")
-
conn.commit()
diff --git a/Задания/task1/Yaroshevskiy/tbot.py b/Задания/task1/Yaroshevskiy/tbot.py
new file mode 100644
index 0000000..900396d
--- /dev/null
+++ b/Задания/task1/Yaroshevskiy/tbot.py
@@ -0,0 +1,50 @@
+import telebot as tb
+import config
+import psycopg2 as ps
+
+
+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
+
+
+def get_data(mess, bot, rows_number: int) -> None:
+ try:
+ product_id = int(mess.text)
+ except BaseException:
+ bot.send_message(mess.chat.id, "Invalid id")
+ return
+
+ if product_id > rows_number:
+ bot.send_message(mess.chat.id, "Id is bigger than number of products")
+ return
+ else:
+ data = exec_query(
+ f"select * from images where id = {product_id}")[0][1:]
+
+ bot.send_message(mess.chat.id, "\n\n".join(data))
+
+
+bot = tb.TeleBot(config.token)
+
+keyboard = tb.types.ReplyKeyboardMarkup()
+keyboard.row("get data")
+
+
+@bot.message_handler(commands=["start"])
+def hi(mess):
+ bot.send_message(mess.chat.id, "HI there!", reply_markup=keyboard)
+
+
+@bot.message_handler(content_types=["text"])
+def f(mess):
+ if mess.text == "get data":
+ row_number = int(exec_query("select count(*) from images")[0][0])
+ bot.send_message(mess.chat.id, f"Write id between 1 and {row_number}")
+ bot.register_next_step_handler(mess, get_data, bot, row_number)
+
+
+bot.polling(non_stop=True)
diff --git a/Задания/task1/nikitin/test2.py b/Задания/task1/nikitin/test2.py
index 23b8205..ccb97a6 100644
--- a/Задания/task1/nikitin/test2.py
+++ b/Задания/task1/nikitin/test2.py
@@ -3,6 +3,7 @@ from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import psycopg2
import wget
+import time
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
cursor = connection.cursor()
@@ -11,6 +12,7 @@ s = Service('D:\Games\data\chromedriver.exe')
browser = webdriver.Chrome(service=s)
browser.get('https://www.volkswagen.ru/polo/')
html_text = browser.page_source
+time.sleep(2)
soup = BeautifulSoup(html_text, 'lxml')
creat_table = """ create table Cars_volks
@@ -25,17 +27,13 @@ prices = soup.find_all('div', class_='avn001-2_price-container')
adresses = soup.find_all('div', class_='avn001-2_dealer-link__text')
pictures = soup.find_all('div', class_='avn001-2_image image__container')
-#for car_name, adress, price in zip(car_names, adresses, prices):
-# print(f"Название машины:{car_name.text} | Адрес диллера: {adress.text} | Цена: {price.text} рублей")
-
for i in range(len(car_names)):
- url = pictures[i].find('img').attrs['src']
- filename = f"c22712\\Задания\\task1\\nikitin\\img\\{i}.jpg"
-# wget.download(url, filename) представим что картинки скачались:)
-
+ url = pictures[i].find('img')['src']
+ filename = f"C:\\Users\\Пользователь\\OneDrive\\Рабочий стол\\pycharm\\c22712\\Задания\\task1\\nikitin\\img\{i}.jpg"
+ wget.download(url, filename)
insert_qwery = f"""INSERT INTO public.Cars_volks(car_name, price, adress, scr)
VALUES ('{car_names[i].text}', '{prices[i].text}', '{adresses[i].text}', '{filename}')""";
- cursor.execute(insert_qwery)
+ #cursor.execute(insert_qwery)
connection.commit()
cursor.close()
diff --git a/Задания/task1/romanov/bdpars.py b/Задания/task1/romanov/bdpars.py
new file mode 100644
index 0000000..82a6a13
--- /dev/null
+++ b/Задания/task1/romanov/bdpars.py
@@ -0,0 +1,43 @@
+import wget
+import psycopg2
+from bs4 import BeautifulSoup
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+connection = psycopg2.connect(host='localhost', dbname='postgres',
+ user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+cr_qwery = """ create table parser
+ (id serial primary key,
+ name varchar(60),
+ price varchar(15),
+ picture varchar(100))"""
+cursor.execute(cr_qwery)
+connection.commit()
+s = Service('C:\Desktop\exe\chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://www.hellride.ru/catalog/zapchasti-dlya-tryukovyh-samokatov/deki')
+html_code = browser.page_source
+soup = BeautifulSoup(html_code, 'lxml')
+name = soup.find_all('span', class_='product-card__title')
+price = soup.find_all('span', class_='product-card__price')
+picture = soup.find_all('img', class_='product-slider__slide-img swiper-lazy swiper-lazy-loaded')
+
+#for prices, names in zip(price, name,):
+ #print(f" название {names.text} ; цена: {prices.text} ")
+for i in range(len(name)):
+ url = picture[i].attrs['src']
+ filename = f"C:\\Users\\Михаил\PycharmProjects\pythonProject8\\venv\Pictures\{i}.jpg"
+ wget.download(url, filename)
+ ins_qwery = f"""insert into public.Parser(name, price, picture)
+ values ('{name[i].text}', '{price[i].text}', '{filename}')"""
+cursor.execute(ins_qwery)
+connection.commit()
+
+cursor.close()
+
+connection.close()
+
+
+
+
+