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] 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 @@ - - + -<<<<<<< HEAD - { - "keyToString": { - "last_opened_file_path": "C:/Users/Honor/c22712" - } -} - -======= - - + + ->>>>>>> d1c29f6 (телеграмм бот) - + - - + + @@ -209,14 +197,7 @@ 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()