commit f5579babc26b6dad00f4fe2a1d51d004b8d6f6f3 Author: ada-dmitry Date: Tue Apr 4 16:23:48 2023 +0300 ipo diff --git a/Python/23.03/DB1 b/Python/23.03/DB1 new file mode 100644 index 0000000..e69de29 diff --git a/Python/23.03/DB1.py b/Python/23.03/DB1.py new file mode 100644 index 0000000..ac16e1b --- /dev/null +++ b/Python/23.03/DB1.py @@ -0,0 +1,42 @@ +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='PythonDB', user='postgres', password='Q1w2e3r4') + +cursor = connection.cursor() + +creat_qwery = """ create table Parser + (id serial primary key, page_name varchar(100), price varchar(10), priceDis varchar(30), mark varchar(10), scr varchar(100))""" + +cursor.execute(creat_qwery) +connection.commit() + +driver = Service('D:\\teach\Prog\chromedriver.exe') +browser = webdriver.Chrome(service=driver) +browser.get('https://amwine.ru/catalog/igristoe_vino_i_shampanskoe/igristoe_vino/') +html_code = browser.page_source +b_soup = BeautifulSoup(html_code, 'lxml') +name = b_soup.find_all('a', class_="catalog-list-item__title js-product-detail-link") +price = b_soup.find_all('span', class_="middle_price") +priceDis = b_soup.find_all('span', class_="baseoldprice") +mark = b_soup.find_all('span', class_="product-rating__rating") +pictures = b_soup.find_all('div', class_="catalog-list-item__img-wrapper") + +for i in range(15): + url = 'https://amwine.ru'+pictures[i].find('a').find('img').attrs['data-src'] + filename = f"Programming\\23.03\img\{i}.jpg" + print(filename) + wget.download(url, filename) + ins_qwery = f"""insert into public.Parser(page_name, price, priceDis, mark, scr) values ('{name[i].text}', '{price[i].text}', '{priceDis[i].text}', '{mark[i].text}', '{filename}')""" + cursor.execute(ins_qwery) + connection.commit() + + + + +cursor.close() + +connection.close() \ No newline at end of file diff --git a/Python/23.03/img/0.jpg b/Python/23.03/img/0.jpg new file mode 100644 index 0000000..a3605fb Binary files /dev/null and b/Python/23.03/img/0.jpg differ diff --git a/Python/23.03/img/1.jpg b/Python/23.03/img/1.jpg new file mode 100644 index 0000000..c7aea3b Binary files /dev/null and b/Python/23.03/img/1.jpg differ diff --git a/Python/23.03/img/10.jpg b/Python/23.03/img/10.jpg new file mode 100644 index 0000000..2dccefe Binary files /dev/null and b/Python/23.03/img/10.jpg differ diff --git a/Python/23.03/img/11.jpg b/Python/23.03/img/11.jpg new file mode 100644 index 0000000..7688e9c Binary files /dev/null and b/Python/23.03/img/11.jpg differ diff --git a/Python/23.03/img/12.jpg b/Python/23.03/img/12.jpg new file mode 100644 index 0000000..c7c0cb4 Binary files /dev/null and b/Python/23.03/img/12.jpg differ diff --git a/Python/23.03/img/13.jpg b/Python/23.03/img/13.jpg new file mode 100644 index 0000000..4c1bf3b Binary files /dev/null and b/Python/23.03/img/13.jpg differ diff --git a/Python/23.03/img/14.jpg b/Python/23.03/img/14.jpg new file mode 100644 index 0000000..bafbe29 Binary files /dev/null and b/Python/23.03/img/14.jpg differ diff --git a/Python/23.03/img/2.jpg b/Python/23.03/img/2.jpg new file mode 100644 index 0000000..c95a406 Binary files /dev/null and b/Python/23.03/img/2.jpg differ diff --git a/Python/23.03/img/3.jpg b/Python/23.03/img/3.jpg new file mode 100644 index 0000000..0aab9e3 Binary files /dev/null and b/Python/23.03/img/3.jpg differ diff --git a/Python/23.03/img/4.jpg b/Python/23.03/img/4.jpg new file mode 100644 index 0000000..576bce6 Binary files /dev/null and b/Python/23.03/img/4.jpg differ diff --git a/Python/23.03/img/5.jpg b/Python/23.03/img/5.jpg new file mode 100644 index 0000000..a7c53ab Binary files /dev/null and b/Python/23.03/img/5.jpg differ diff --git a/Python/23.03/img/6.jpg b/Python/23.03/img/6.jpg new file mode 100644 index 0000000..4b3ea13 Binary files /dev/null and b/Python/23.03/img/6.jpg differ diff --git a/Python/23.03/img/7.jpg b/Python/23.03/img/7.jpg new file mode 100644 index 0000000..2cd8120 Binary files /dev/null and b/Python/23.03/img/7.jpg differ diff --git a/Python/23.03/img/8.jpg b/Python/23.03/img/8.jpg new file mode 100644 index 0000000..a22eee2 Binary files /dev/null and b/Python/23.03/img/8.jpg differ diff --git a/Python/23.03/img/9.jpg b/Python/23.03/img/9.jpg new file mode 100644 index 0000000..ceb59fe Binary files /dev/null and b/Python/23.03/img/9.jpg differ diff --git a/Python/SortVibor.py b/Python/SortVibor.py new file mode 100644 index 0000000..d38560f --- /dev/null +++ b/Python/SortVibor.py @@ -0,0 +1,30 @@ +''' +print("Введите размер массива: ") +n = int(input()) +a = [int(input()) for i in range(n)] +''' +a = [4,3,2,5,1] +b = a.copy() +def sortSelect(arr): + for i in range(len(arr)-1): + ind = i + for j in range(i+1, len(arr)): + if(arr[ind]>arr[j]): + ind = j + arr[i], arr[ind] = arr[ind], arr[i] + return arr + + +def sortInsert(arr): + for i in range(len(arr)): + j = i-1 + x = arr[i] + while((arr[j]>x)and(j>=0)): + arr[j+1] = arr[j] + j -= 1 + arr[j+1] = x + return arr +#meow + + +print(sortSelect(a), sortInsert(b)) \ No newline at end of file diff --git a/Python/other/NMisha.py b/Python/other/NMisha.py new file mode 100644 index 0000000..b19fa8b --- /dev/null +++ b/Python/other/NMisha.py @@ -0,0 +1,43 @@ +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() + +s = Service('D:\Games\data\chromedriver.exe') +browser = webdriver.Chrome(service=s) +browser.get('https://www.volkswagen.ru/polo/') +html_text = browser.page_source +soup = BeautifulSoup(html_text, 'lxml') + +# creat_table = """ create table Cars_volks +# (id serial primary key, car_name varchar(20), +# price varchar(15), adress varchar(40), +# scr varchar(100)) """ +#cursor.execute(creat_table) +# connection.commit() + +car_names = soup.find_all('div', class_='avn001-2_name') +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(4): + url = pictures[i].find('img').attrs['src'] + filename = f"Programming\\other\\img\\img{i}.jpg" + print(filename) + 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) +# connection.commit() + +# cursor.close() +# connection.close() \ No newline at end of file diff --git a/Python/other/Vova1.py b/Python/other/Vova1.py new file mode 100644 index 0000000..6da424c --- /dev/null +++ b/Python/other/Vova1.py @@ -0,0 +1,33 @@ +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/') +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"}) +Delivery_Price = soup.find_all(attrs={"class": "catalog_delivery"}) +Image = soup.find_all('div', 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), Delivery_Price varchar(20), src varchar(110))''' +cursor.execute(create_q) +connection.commit() + +for j in range(10): + url = 'https://flawery.ru'+Image[j].find('a').find('img').attrs['src'] + print(url) + tempf = f'C:\\Users\\user\\Desktop\\FHWDB{j}.jpg' + wget.download(url, tempf) + insert_query = f'''INSERT into public.Parse(Name, Price, Delivery_Time, Delivery_Price, scr) values ('{Name[j].text}', '{Price[j].text}', '{Delivery_Time[j].text}', '{Delivery_Price[j].text}', '{tempf}') ''' + cursor.execute(insert_query) + connection.commit() + +cursor.close() +connection.close() \ No newline at end of file diff --git a/Python/other/img/img0.jpg b/Python/other/img/img0.jpg new file mode 100644 index 0000000..2c2222e Binary files /dev/null and b/Python/other/img/img0.jpg differ diff --git a/Python/other/img/img1.jpg b/Python/other/img/img1.jpg new file mode 100644 index 0000000..46a6360 Binary files /dev/null and b/Python/other/img/img1.jpg differ diff --git a/Python/other/img/img2.jpg b/Python/other/img/img2.jpg new file mode 100644 index 0000000..c2b4556 Binary files /dev/null and b/Python/other/img/img2.jpg differ diff --git a/Python/other/img/img3.jpg b/Python/other/img/img3.jpg new file mode 100644 index 0000000..46a6360 Binary files /dev/null and b/Python/other/img/img3.jpg differ diff --git a/Python/parser.py b/Python/parser.py new file mode 100644 index 0000000..ff3252b --- /dev/null +++ b/Python/parser.py @@ -0,0 +1,40 @@ + +#Вариант с пары +''' +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +import time + +S = Service('D:\teach\Prog\chromedriver.exe') #Открыли драйвер для хрома +browser = webdriver.Chrome(service=S) #Инициировали в отдельную переменную +browser.get('https://www.kinopoisk.ru/lists/movies/top250/') +html_text = browser.page_source +time.sleep(20) +soup = BeautifulSoup(html_text, 'lxml') +films = soup.find_all('div', class_='base-movie-main-info_mainInfo__ZL_u3') + +print(soup) +print(films) + +for film in films: + print(film.text) +''' +#Домашка + +from bs4 import BeautifulSoup +from selenium import webdriver +from selenium.webdriver.chrome.service import Service + +driver = Service('D:\teach\Prog\chromedriver.exe') +browser = webdriver.Chrome(service=driver) +browser.get('https://hmbrussia.ru/regional-office/') +html_code = browser.page_source +b_soup = BeautifulSoup(html_code, 'lxml') +name = b_soup.find_all('div', class_="ps-xl-3 ms-xl-3") + +print(b_soup) +print(name) + +for i in name: + print(i.text)