mirror of
https://github.com/KUlishevgeniy/c22712.git
synced 2026-09-24 08:00:22 +00:00
Delete FHWDB.py
This commit is contained in:
@@ -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()
|
|
||||||
Reference in New Issue
Block a user