mirror of
https://github.com/ada-dmitry/PyProg_ada.git
synced 2026-09-24 01:10:40 +00:00
ss
This commit is contained in:
+12
-8
@@ -3,8 +3,11 @@ import wget
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.service import Service
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
import config
|
||||||
|
|
||||||
# Парсер и загрузчик в БД//Антипенко Дмитрий
|
# Парсер и загрузчик в БД//Антипенко Дмитрий
|
||||||
connection = psycopg2.connect(host='localhost', dbname='PythonDB', user='postgres', password='Q1w2e3r4')
|
connection = psycopg2.connect(
|
||||||
|
host=hostname, dbname=databname, user=username, password=passw)
|
||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
@@ -14,19 +17,22 @@ creat_qwery = """ create table Parser
|
|||||||
cursor.execute(creat_qwery)
|
cursor.execute(creat_qwery)
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
driver = Service('D:\\teach\Prog\chromedriver.exe')
|
driver = Service('D:\\teach\Prog\chromedriver.exe')
|
||||||
browser = webdriver.Chrome(service=driver)
|
browser = webdriver.Chrome(service=driver)
|
||||||
browser.get('https://amwine.ru/catalog/igristoe_vino_i_shampanskoe/igristoe_vino/')
|
browser.get(
|
||||||
|
'https://amwine.ru/catalog/igristoe_vino_i_shampanskoe/igristoe_vino/')
|
||||||
html_code = browser.page_source
|
html_code = browser.page_source
|
||||||
b_soup = BeautifulSoup(html_code, 'lxml')
|
b_soup = BeautifulSoup(html_code, 'lxml')
|
||||||
name = b_soup.find_all('a', class_="catalog-list-item__title js-product-detail-link")
|
name = b_soup.find_all(
|
||||||
|
'a', class_="catalog-list-item__title js-product-detail-link")
|
||||||
price = b_soup.find_all('span', class_="middle_price")
|
price = b_soup.find_all('span', class_="middle_price")
|
||||||
priceDis = b_soup.find_all('span', class_="baseoldprice")
|
priceDis = b_soup.find_all('span', class_="baseoldprice")
|
||||||
mark = b_soup.find_all('span', class_="product-rating__rating")
|
mark = b_soup.find_all('span', class_="product-rating__rating")
|
||||||
pictures = b_soup.find_all('div', class_="catalog-list-item__img-wrapper")
|
pictures = b_soup.find_all('div', class_="catalog-list-item__img-wrapper")
|
||||||
|
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
url = 'https://amwine.ru'+pictures[i].find('a').find('img').attrs['data-src']
|
url = 'https://amwine.ru' + \
|
||||||
|
pictures[i].find('a').find('img').attrs['data-src']
|
||||||
filename = f"Programming\\23.03\img\{i}.jpg"
|
filename = f"Programming\\23.03\img\{i}.jpg"
|
||||||
print(filename)
|
print(filename)
|
||||||
wget.download(url, filename)
|
wget.download(url, filename)
|
||||||
@@ -35,8 +41,6 @@ for i in range(15):
|
|||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
|||||||
|
hostname = "localhost"
|
||||||
|
databname = "PythonDB"
|
||||||
|
username = "postgres"
|
||||||
|
passw = "Q1w2e3r4"
|
||||||
Reference in New Issue
Block a user