From 474ebc091b2beb542cb0261517b0b52e26e9992e Mon Sep 17 00:00:00 2001 From: pErfEcto2 Date: Sun, 26 Mar 2023 22:08:51 +0300 Subject: [PATCH 01/11] minor changes --- Задания/task1/Yaroshevskiy/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Задания/task1/Yaroshevskiy/main.py b/Задания/task1/Yaroshevskiy/main.py index 945ddf8..11eea2c 100644 --- a/Задания/task1/Yaroshevskiy/main.py +++ b/Задания/task1/Yaroshevskiy/main.py @@ -21,8 +21,11 @@ with psyc.connect(dbname="db_for_parse", user="perfecto") as conn: img_tag = product.find(attrs={"class": "imagef"}).find("img") title = img_tag.attrs.get("alt") image = url + img_tag.attrs.get("src") + price = product.find(attrs={"class": "product-price"}).text + desc = product.find(attrs={"class": "product-desc"}).text download(url + img_tag.attrs.get("src"), f"images/{i}.jpg") - cursor.execute(f"insert into images(link, name) values ('{image}', '{title}')") + cursor.execute(f"""insert into images(link, name, price, description, file) + values ('{image}', '{title}', '{price}', '{desc}', 'images/{i}.jpg')""") conn.commit() From ab058872aa4d9c2bef39ce48a961182d57115e78 Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:05:27 +0300 Subject: [PATCH 02/11] Delete FHWDB.py --- Задания/task1/Epifanov/FHWDB.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 Задания/task1/Epifanov/FHWDB.py diff --git a/Задания/task1/Epifanov/FHWDB.py b/Задания/task1/Epifanov/FHWDB.py deleted file mode 100644 index 75f4a5b..0000000 --- a/Задания/task1/Epifanov/FHWDB.py +++ /dev/null @@ -1,32 +0,0 @@ -from bs4 import BeautifulSoup -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -import psycopg2 -import wget - -browser = webdriver.Chrome(service=Service('C:\Desktop\exe\chromedriver.exe')) -browser.get('https://flawery.ru/moscow/bouquets/event-yanvary25/?min=0&max=max&sorting=discount&filter_24h=on') -soup = BeautifulSoup(browser.page_source, "lxml") -Name = soup.find_all(attrs={"class": "catalog_title"}) -Price = soup.find_all(attrs={"class": "catalog_price_now"}) -Delivery_Time = soup.find_all(attrs={"class": "catalog_express"}) -Discount = soup.find_all(attrs={"class": "catalog_sale"}) -Image = soup.find_all(attrs={"class": "catalog_item catalog_item_popup"}) - -connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') -cursor = connection.cursor() -create_q = '''CREATE TABLE Parse - (ID serial primary key, Name varchar(100), Price varchar(9), Delivery_Time varchar(25), Discount varchar(10), src varchar(110))''' -cursor.execute(create_q) -connection.commit() - -for j in range(60): - url = 'https://flawery.ru'+Image[j].find('a').find('picture').find('img').attrs['src'] - tempf = f"C:\\Users\\user\\Desktop\\FHWDB{j}.jpg" - wget.download(url, tempf) - insert_query = f'''INSERT into public.Parse(Name, Price, Delivery_Time, Discount, src) values ('{Name[j].text}', '{Price[j].text}', '{Delivery_Time[j].text}', '{Discount[j].text}', '{tempf}') ''' - cursor.execute(insert_query) - -connection.commit() -cursor.close() -connection.close() From 0496fac352a73805186e85d111120e3b2e8ad183 Mon Sep 17 00:00:00 2001 From: VladEpifanov Date: Sun, 26 Mar 2023 23:08:15 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D1=81=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0=20=D0=B2=20=D0=91=D0=94?= =?UTF-8?q?(=D0=B4=D0=B7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Epifanov/FHWDB.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Задания/task1/Epifanov/FHWDB.py diff --git a/Задания/task1/Epifanov/FHWDB.py b/Задания/task1/Epifanov/FHWDB.py new file mode 100644 index 0000000..66aa507 --- /dev/null +++ b/Задания/task1/Epifanov/FHWDB.py @@ -0,0 +1,34 @@ +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +import psycopg2 +import wget + +browser = webdriver.Chrome(service=Service('C:\Desktop\exe\chromedriver.exe')) +browser.get('https://flawery.ru/moscow/bouquets/color-blue/?min=0&max=max&sorting=discount') +soup = BeautifulSoup(browser.page_source, "lxml") +Name = soup.find_all(attrs={"class": "catalog_title"}) +Price = soup.find_all(attrs={"class": "catalog_price_now"}) +Discount = soup.find_all(attrs={"class": "catalog_sale"}) +Image = soup.find_all(attrs={"class": "catalog_item catalog_item_popup"}) + +connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') +cursor = connection.cursor() +create_q = '''CREATE TABLE Parse + (ID serial primary key, Name varchar(100), Price varchar(9), Discount varchar(10), src varchar(110))''' +cursor.execute(create_q) +connection.commit() + +for j in range(60): + url = 'https://flawery.ru'+Image[j].find('a').find('picture').find('img').attrs['src'] + tempf = f"C:\\Users\\user\\PFDB{j}.jpg" + wget.download(url, tempf) + insert_query = f'''INSERT into public.Parse(Name, Price, Discount, src) values ('{Name[j].text}', '{Price[j].text}', '{Discount[j].text}', '{tempf}') ''' + cursor.execute(insert_query) +connection.commit() + +cursor.execute("SELECT * from Parse") +print(cursor.fetchall()) + +cursor.close() +connection.close() From 1604cf223285bf37d24c0ded5900fe0ffaeb5c23 Mon Sep 17 00:00:00 2001 From: Dronminator Date: Mon, 27 Mar 2023 13:23:10 +0300 Subject: [PATCH 04/11] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D1=81=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=20=D1=81=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Lahin/postgres.py | 48 +++++++++++++-------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py index 0ca1bb2..cfa0920 100644 --- a/Задания/task1/Lahin/postgres.py +++ b/Задания/task1/Lahin/postgres.py @@ -7,65 +7,55 @@ import time i = 1 s = Service("С:\DATA\ChromeDriver\chromedriver.exe") browser = webdriver.Chrome(service=s) -browser.get("https://www.mvideo.ru/noutbuki-planshety-komputery-8/noutbuki-118?from=under_search") +browser.get("https://www.mvideo.ru/noutbuki-planshety-komputery-8/noutbuki-118/f/tolko-v-nalichii=da?from=under_search") +time.sleep(5) +""" height = browser.execute_script("return document.body.scrollHeight") time.sleep(4) -while 900*i < height: - height = browser.execute_script("return document.body.scrollHeight") - browser.execute_script(f"window.scrollTo(0,{900*i})") +for i in range(10): + browser.execute_script(f"window.scrollTo(0, {1000*i})") time.sleep(1) - i+=1 +""" html_text = browser.page_source soup = BeautifulSoup(html_text, 'lxml') productst = soup.find_all('a', class_="product-title__text") pricest = soup.find_all('span', class_="price__main-value") -features = soup.find_all('ul', class_="product-feature-list product-feature-list--undefined") -pictures = soup.find_all('img', class_="product-picture__img product-picture__img--list") -products, prices, diagonals, resolutions, CPUs, RAMs, Graphics_controllers, Volumes = [],[],[],[],[],[],[],[] -for i in range(len(productst)): - products.append(productst[i].text.strip()) - prices.append(pricest[i].text.replace("\xa0", "").strip()) -for feature in features: - u = feature.text - diagonals.append(u[20:u.find("\"",20)+1]) - resolutions.append(u[u.find("\"",20)+2:u.find(".", 23)+1]) - CPUs.append(u[u.find("Процессор",20)+9:u.find("ГГц",20)+3].replace("\xa0","")) - RAMs.append(" ".join(u[u.find("(RAM)",20)+5:u.find("Графический контроллер")].split())) - Graphics_controllers.append(u[u.find("Графический контроллер")+22:u.rfind("Объем")-2]) - Volumes.append(u[u.rfind("Объем")+6:].replace("\xa0", "").strip()) -for i in range(len(Volumes)): - u = Volumes[i] - if u.rfind("D")!=-1: Volumes[i] = u[:u.rfind("D")+1]+ " " + u[u.rfind("D")+1:] - else: Volumes[i] = u[:u.rfind("С")+1]+ " " + u[u.rfind("С")+1:] +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') 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), CPU varchar(50), -RAM varchar(10), +RAM varchar(15), Graphics_Controller varchar(40), 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(products)): - url = "https://"+pictures[i]['src'] +for i in range(len(productst)): + url = "https://"+pictures[i].find('img')['src'] filename = f"C:\DATA\Images\{i+1}.jpg" + u = [] + for j in range(10): + 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 - ('{products[i]}', '{prices[i]}', '{diagonals[i]}', '{resolutions[i]}', '{CPUs[i]}', '{RAMs[i]}', '{Graphics_controllers[i]}', '{Volumes[i]}', '{filename}');""" + ('{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() - From 57870acb2f37cab42f7038a1187e8fe14e0103b3 Mon Sep 17 00:00:00 2001 From: Dronminator <124861705+Dronminator@users.noreply.github.com> Date: Mon, 27 Mar 2023 13:25:37 +0300 Subject: [PATCH 05/11] Delete postgresEasy.py --- Задания/task1/Lahin/postgresEasy.py | 42 ----------------------------- 1 file changed, 42 deletions(-) delete mode 100644 Задания/task1/Lahin/postgresEasy.py diff --git a/Задания/task1/Lahin/postgresEasy.py b/Задания/task1/Lahin/postgresEasy.py deleted file mode 100644 index 375b40d..0000000 --- a/Задания/task1/Lahin/postgresEasy.py +++ /dev/null @@ -1,42 +0,0 @@ -import psycopg2 -import wget -from bs4 import BeautifulSoup -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -s = Service("С:\DATA\ChromeDriver\chromedriver.exe") -browser = webdriver.Chrome(service=s) -browser.get("https://online.metro-cc.ru/virtual/assortiment_rioba-4887?from=under_search&page=2") -html_text = browser.page_source -soup = BeautifulSoup(html_text, 'lxml') -productst = soup.find_all('span', class_="product-card-name__text") -pricest = soup.find_all('span', class_="product-price__sum-rubles") -pictures = soup.find_all('img', class_="product-card-photo__image") -connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') -cursor = connection.cursor() -products, prices = [], [] -for i in range(len(productst)): - products.append(productst[i].text.replace("\n", "").strip()) - prices.append(pricest[i].text+" Р/шт") -insert = """CREATE TABLE public.Chocolate( -id serial primary key, -product varchar(100), -price varchar(25), -src varchar(50) -); -""" -cursor.execute(insert) -connection.commit() -for i in range(len(products)): - url = pictures[i]['src'] - filename = f"C:\DATA\Images2\{i+1}.jpg" - wget.download(url, filename) - insert = f"""INSERT INTO public.Chocolate( - product, price, src) - VALUES - ('{products[i]}', '{prices[i]}', '{filename}');""" - cursor.execute(insert) - connection.commit() -cursor.execute("select * from Chocolate") -print("Результат", cursor.fetchall()) -cursor.close() -connection.close() From bf11850a862829324db009e9593a97b3a3a146a3 Mon Sep 17 00:00:00 2001 From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com> Date: Tue, 28 Mar 2023 21:10:44 +0300 Subject: [PATCH 06/11] Update FHWDB.py --- Задания/task1/Epifanov/FHWDB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Задания/task1/Epifanov/FHWDB.py b/Задания/task1/Epifanov/FHWDB.py index 66aa507..7a06660 100644 --- a/Задания/task1/Epifanov/FHWDB.py +++ b/Задания/task1/Epifanov/FHWDB.py @@ -15,7 +15,7 @@ Image = soup.find_all(attrs={"class": "catalog_item catalog_item_popup"}) connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() create_q = '''CREATE TABLE Parse - (ID serial primary key, Name varchar(100), Price varchar(9), Discount varchar(10), src varchar(110))''' + (ID serial primary key, Name varchar(100), Price varchar(9), Discount varchar(10), src_of_picture varchar(50))''' cursor.execute(create_q) connection.commit() @@ -23,7 +23,7 @@ for j in range(60): url = 'https://flawery.ru'+Image[j].find('a').find('picture').find('img').attrs['src'] tempf = f"C:\\Users\\user\\PFDB{j}.jpg" wget.download(url, tempf) - insert_query = f'''INSERT into public.Parse(Name, Price, Discount, src) values ('{Name[j].text}', '{Price[j].text}', '{Discount[j].text}', '{tempf}') ''' + insert_query = f'''INSERT into public.Parse(Name, Price, Discount, src_of_picture) values ('{Name[j].text}', '{Price[j].text}', '{Discount[j].text}', '{tempf}') ''' cursor.execute(insert_query) connection.commit() From 0e471eed814b6b15b26483b5cfd897e358bc3ef0 Mon Sep 17 00:00:00 2001 From: polevev <124861891+polevev@users.noreply.github.com> Date: Tue, 28 Mar 2023 21:35:22 +0300 Subject: [PATCH 07/11] Create Parsing --- Задания/task1/Markovich/Parsing | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Задания/task1/Markovich/Parsing diff --git a/Задания/task1/Markovich/Parsing b/Задания/task1/Markovich/Parsing new file mode 100644 index 0000000..62aaee7 --- /dev/null +++ b/Задания/task1/Markovich/Parsing @@ -0,0 +1,40 @@ +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +import wget +import psycopg2 + +connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') +cursor = connection.cursor() + +s = Service(r"C:\\Documents\\data\\chromedriver.exe") +browser = webdriver.Chrome(service=s) +browser.get('https://www.citilink.ru/catalog/smartfony/') +html_text = browser.page_source +b_soup = BeautifulSoup(html_text, 'lxml') + +insert_qwery = """create table phones\n +(id serial primary key, name varchar(100), price varchar(100),delivery varchar(100), pictures varchar(100))""" + +cursor.execute(insert_qwery) +connection.commit() + +phone_names = b_soup.find_all('a', class_="app-catalog-9gnskf e1259i3g0") +phone_price = b_soup.find_all('span', class_="e1j9birj0 e106ikdt0 app-catalog-j8h82j e1gjr6xo0") +phone_delivery = b_soup.find_all('div', class_="e16h9msl0 app-catalog-1fnzrtt e15ufesp0") +pictures = b_soup.find_all('div', class_="app-catalog-zugobn e1o1y6qd0") + +for i in range(15): + url = 'https://www.citilink.ru/catalog/smartfony/' + filename = f"C:\\Users\\mark6\\OneDrive\\Desktop\\БД\\img\\{i}.jpg" + wget.download(url, filename) + ins_qwery = f"""INSERT INTO public.phones(name, price, delivery, pictures)\n + VALUES ('{phone_names[i].text}', '{phone_price[i].text}', '{phone_delivery[i].text}', '{filename}');""" + cursor.execute(ins_qwery) + connection.commit() + +cursor.execute("Select * from phones") +print(cursor.fetchall()) + +cursor.close() +connection.close() From 265ffac7f037b7fb435aadf7522d75afe88005ce Mon Sep 17 00:00:00 2001 From: Harutyun Date: Tue, 28 Mar 2023 22:31:53 +0300 Subject: [PATCH 08/11] parser with database --- Задания/task1/Garanyan/main.py | 39 +++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Задания/task1/Garanyan/main.py b/Задания/task1/Garanyan/main.py index ac6f8f2..8e6da15 100644 --- a/Задания/task1/Garanyan/main.py +++ b/Задания/task1/Garanyan/main.py @@ -1,12 +1,35 @@ from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.chrome.service import Service +import psycopg2 +import wget -s = Service("E:\data\chromedriver.exe") -browser = webdriver.Chrome(service=s) -browser.get("https://ria.ru/") -html_text = browser.page_source -soup = BeautifulSoup(html_text, 'lxml') -news = soup.find_all('div', class_='cell cell-list') -for new in news: - print(new.text) +browser = webdriver.Chrome(service=Service('E:\data\chromedriver.exe')) +browser.get('https://8956food.ru/') +soup = BeautifulSoup(browser.page_source, "lxml") + +Name = soup.find_all(attrs={"class": "subtitle"}) +Price = soup.find_all(attrs={"class": "price"}) +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))''' +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): + url = Image[j].find('img').attrs['src'] + tempf = f"C:\\Users\\Harutyun\\Desktop\\prog\\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) +connection.commit() + +cursor.execute("SELECT * from Food") +print(cursor.fetchall()) + +cursor.close() +connection.close() \ No newline at end of file From aa40ff64facbaf950b6189b1bd1ba3f70d883016 Mon Sep 17 00:00:00 2001 From: Sklvd Date: Wed, 29 Mar 2023 16:55:10 +0300 Subject: [PATCH 09/11] parsing in db2 --- Задания/task1/Kluchinskaya1/parsing_2.py | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Задания/task1/Kluchinskaya1/parsing_2.py diff --git a/Задания/task1/Kluchinskaya1/parsing_2.py b/Задания/task1/Kluchinskaya1/parsing_2.py new file mode 100644 index 0000000..df08832 --- /dev/null +++ b/Задания/task1/Kluchinskaya1/parsing_2.py @@ -0,0 +1,29 @@ +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +from wget import download +import psycopg2 +connection = psycopg2.connect(host='localhost', dbname='dbdata', + user='postgres', password='Q1w2e3r4') +cursor=connection.cursor() +s = Service('C:\\Users\\Dasha\\Desktop\\Progect\\chromedriver.exe') +browser = webdriver.Chrome(service=s) +browser = webdriver.Chrome() +url = 'https://www.tretyakovgallery.ru/' +browser.get(url) +html_text=browser.page_source +soup = BeautifulSoup(html_text, 'lxml') +products = soup.find_all(attrs={"class": "building-item"}) +for i, product in enumerate(products): + link = product.find("img").attrs.get("src") + tag = product.find("strong") + name = product.find(attrs={"class": "building-item__title"}) + description = product.find(attrs={"class": "building-item__description"}) + if tag is not None: + download(url + link, f"img\\{i}.jpg") + cursor.execute(f"""INSERT INTO public.parsing(url, workhours, name, description, filename) + VALUES + ( '{url + link}', '{tag.text}', '{name.text.strip()}', '{description.text.strip()}', 'img\\{i}.jpg')""") +connection.commit() +cursor.close() +connection.close() \ No newline at end of file From 7096a60830ff8d223e3bbf74c60895d116efb6aa Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:40:52 +0300 Subject: [PATCH 10/11] Parcing --- Задания/task1/Uskova/DataBaze.py | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Задания/task1/Uskova/DataBaze.py diff --git a/Задания/task1/Uskova/DataBaze.py b/Задания/task1/Uskova/DataBaze.py new file mode 100644 index 0000000..e2bc77e --- /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(2): + 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() \ No newline at end of file From d9014da5ab806b659d229bcd358ea4ae3e964a3c Mon Sep 17 00:00:00 2001 From: eauskova <124862140+eauskova@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:46:57 +0300 Subject: [PATCH 11/11] Update DataBaze.py --- Задания/task1/Uskova/DataBaze.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Задания/task1/Uskova/DataBaze.py b/Задания/task1/Uskova/DataBaze.py index e2bc77e..b3f2f60 100644 --- a/Задания/task1/Uskova/DataBaze.py +++ b/Задания/task1/Uskova/DataBaze.py @@ -26,7 +26,7 @@ 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(2): +for i in range(10): url = picture[i].find('img').attrs['src'] file = f"C:\\Users\\Yekaterina\\Desktop\\baza\\pic{i}.JPG" wget.download(url, file) @@ -36,4 +36,4 @@ for i in range(2): connection.commit() cursor.close() -connection.close() \ No newline at end of file +connection.close()