mirror of
https://github.com/ada-dmitry/PyProg_ada.git
synced 2026-09-24 09:20:44 +00:00
reboot rep
This commit is contained in:
@@ -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()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Reference in New Issue
Block a user