relocation
@@ -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()
|
||||
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 126 KiB |
@@ -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))
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
@@ -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)
|
||||