Merge remote-tracking branch 'origin/master'
# Conflicts: # .idea/.name
@@ -1 +1,5 @@
|
||||
parcing.py
|
||||
<<<<<<< HEAD
|
||||
parcing.py
|
||||
=======
|
||||
Work with driver.py
|
||||
>>>>>>> origin/master
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<changelist name="Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]" date="1676412217607" recycled="false" toDelete="true">
|
||||
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_15_02_2023_1_03_[Changes]/shelved.patch" />
|
||||
<option name="DESCRIPTION" value="Uncommitted changes before Update at 15.02.2023 1:03 [Changes]" />
|
||||
</changelist>
|
||||
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Gusev.iml" filepath="$PROJECT_DIR$/.idea/Gusev.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
print('Hello, World!')
|
||||
@@ -0,0 +1,56 @@
|
||||
from bs4 import BeautifulSoup # подключение к библиотекам парсинга и работы с базами данных
|
||||
import psycopg2
|
||||
from wget import download
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
|
||||
S = Service("D:\Драйвер\chromedriver.exe")
|
||||
browser = webdriver.Chrome(service=S)
|
||||
browser.get('https://ultrasport.ru/catalog/velosipedy/gornye_velosipedy/') # подключение к сайту, с которого будем парсить данные
|
||||
html_text = browser.page_source # сохранение html кода страницы в переменную html_text
|
||||
soup = BeautifulSoup(html_text, 'lxml') # преобразуем код в дерево объектов
|
||||
|
||||
info = soup.find_all('div', class_="inner_wrap TYPE_1") # поиск всех описывающих товар общих тэгов
|
||||
|
||||
try:
|
||||
connection = psycopg2.connect( # подключение к базе данных
|
||||
host='localhost',
|
||||
dbname='Bicycles',
|
||||
user='postgres',
|
||||
password='Q1w2e3r4'
|
||||
)
|
||||
connection.autocommit = True # настройка автоматического комита
|
||||
|
||||
with connection.cursor() as cursor: # создание таблицы в базе данных
|
||||
cursor.execute(
|
||||
"""CREATE TABLE bikes(
|
||||
id serial PRIMARY KEY,
|
||||
bike_name varchar(100) NOT NULL,
|
||||
bike_view varchar(1000) NOT NULL,
|
||||
bike_price varchar(100) NOT NULL,
|
||||
bike_availability varchar(100) NOT NULL);
|
||||
"""
|
||||
)
|
||||
with connection.cursor() as cursor: # заполнение таблицы данным, которые мы спарсили с сайта
|
||||
for i, item in enumerate(info):
|
||||
name = item.find('a', class_="dark_link js-notice-block__title option-font-bold font_sm").text.strip()
|
||||
price = item.find('div', class_="price only_price font-bold font_mxs").text.strip()
|
||||
enough = item.find('span', class_="value font_sxs").text.strip()
|
||||
p_src = item.find('img', class_="lazy img-responsive").get("src")
|
||||
download(p_src, f"images/{i+1}.jpg")
|
||||
cursor.execute(
|
||||
f"""INSERT INTO public.bikes(
|
||||
bike_name, bike_view, bike_price, bike_availability)
|
||||
VALUES
|
||||
('{name}','images/{i+1}.jpg','{price}','{enough}');"""
|
||||
)
|
||||
|
||||
|
||||
except Exception as _ex: # обработка ошибок
|
||||
print("[INFO] ERROR", _ex)
|
||||
|
||||
finally: # завершение подключения
|
||||
if connection:
|
||||
connection.close()
|
||||
print("[INFO] Connection closed")
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,61 @@
|
||||
from bs4 import BeautifulSoup # подключение к библиотекам парсинга и работы с базами данных
|
||||
import psycopg2
|
||||
from wget import download
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
|
||||
S = Service("D:\Драйвер\chromedriver.exe")
|
||||
browser = webdriver.Chrome(service=S)
|
||||
browser.get('https://ultrasport.ru/catalog/velosipedy/gornye_velosipedy/') # подключение к сайту, с которого будем парсить данные
|
||||
html_text = browser.page_source # сохранение html кода страницы в переменную html_text
|
||||
soup = BeautifulSoup(html_text, 'lxml') # преобразуем код в дерево объектов
|
||||
|
||||
info = soup.find_all('div', class_="inner_wrap TYPE_1") # поиск всех описывающих товар общих тэгов
|
||||
|
||||
try:
|
||||
connection = psycopg2.connect( # подключение к базе данных
|
||||
host='localhost',
|
||||
dbname='Bicycles',
|
||||
user='postgres',
|
||||
password='Q1w2e3r4'
|
||||
)
|
||||
connection.autocommit = True # настройка автоматического комита
|
||||
|
||||
with connection.cursor() as cursor: # создание таблицы в базе данных
|
||||
cursor.execute(
|
||||
"""CREATE TABLE bikes(
|
||||
id serial PRIMARY KEY,
|
||||
bike_name varchar(100) NOT NULL,
|
||||
bike_view varchar(1000) NOT NULL,
|
||||
bike_price varchar(100) NOT NULL,
|
||||
bike_availability varchar(100) NOT NULL);
|
||||
"""
|
||||
)
|
||||
with connection.cursor() as cursor: # заполнение таблицы данным, которые мы спарсили с сайта
|
||||
for i, item in enumerate(info):
|
||||
name = item.find('a', class_="dark_link js-notice-block__title option-font-bold font_sm").text.strip()
|
||||
price = item.find('div', class_="price only_price font-bold font_mxs").text.strip()
|
||||
enough = item.find('span', class_="value font_sxs").text.strip()
|
||||
p_src = item.find('img', class_="lazy img-responsive").get("src")
|
||||
download(p_src, f"images/{i+1}.jpg")
|
||||
cursor.execute(
|
||||
f"""INSERT INTO public.bikes(
|
||||
bike_name, bike_view, bike_price, bike_availability)
|
||||
VALUES
|
||||
('{name}','images/{i+1}.jpg','{price}','{enough}');"""
|
||||
)
|
||||
|
||||
|
||||
except Exception as _ex: # обработка ошибок
|
||||
print("[INFO] ERROR", _ex)
|
||||
|
||||
finally: # завершение подключения
|
||||
if connection:
|
||||
connection.close()
|
||||
print("[INFO] Connection closed")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Проверка работы.
|
||||
@@ -0,0 +1,54 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium.webdriver import Chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
import time
|
||||
import wget
|
||||
import psycopg2
|
||||
import re
|
||||
s = Service('C:\data\hrome\chromedriver.exe')
|
||||
browser = webdriver.Chrome(service=s)
|
||||
browser.get('https://music.yandex.ru/chart')
|
||||
time.sleep (1)
|
||||
html_text = browser.page_source
|
||||
soup = BeautifulSoup(html_text, 'lxml')
|
||||
Трек=soup.find_all('a', class_='d-track__title deco-link deco-link_stronger')
|
||||
Длительность=soup.find_all('div', class_='d-track__info d-track__nohover')
|
||||
Автор=soup.find_all('span', class_='d-track__artists')
|
||||
Картинки=soup.find_all('img', class_='entity-cover__image deco-pane')
|
||||
str_Картинки=[]
|
||||
for i in range(len(Картинки)):
|
||||
str_Картинки.append(Картинки[i])
|
||||
str_Картинки=str(str_Картинки)
|
||||
str_Картинки=re.findall(r'src="(.*?)"',str_Картинки)
|
||||
for i in range(len(str_Картинки)):
|
||||
str_Картинки[i]='https:'+str_Картинки[i]
|
||||
#for i in range(len(str_cartinki)):
|
||||
#wget.download(str_cartinki[i], 'TOP'+str((i+1))+'.jpeg')
|
||||
|
||||
|
||||
connection = psycopg2.connect(dbname = 'dbdata',
|
||||
user='postgres', password='Q1w2e3r4',
|
||||
host='localhost')
|
||||
cursor=connection.cursor()
|
||||
creat_table="""CREATE TABLE music
|
||||
(id serial primary key, "Трек" varchar(100),
|
||||
"Длительность" varchar(100),
|
||||
"Автор" varchar(100),
|
||||
"Картинки" varchar(100))"""
|
||||
cursor.execute(creat_table)
|
||||
connection.commit()
|
||||
for Трек, Длительность, Автор, Картинки in zip(Трек, Автор, Длительность, Картинки):
|
||||
qwery=f"""INSERT INTO public.music(
|
||||
Трек, Длительность, Автор, Картинки)
|
||||
VALUES
|
||||
('{Трек.text}','{Длительность.text}','{Автор.text}', '{Картинки.text}' )"""
|
||||
cursor.execute(qwery)
|
||||
connection.commit()
|
||||
for i in range(1,len(str_Картинки)+1):
|
||||
puti = r'C:\Users\kingo\PycharmProjects\pythonProject2\TOP' + str(i) + '.jpeg'
|
||||
qwery=f"""UPDATE public.music
|
||||
SET Картинки='{puti}'
|
||||
WHERE id={i}"""
|
||||
cursor.execute(qwery)
|
||||
connection.commit()
|
||||
@@ -27,7 +27,7 @@ item.pop(8)
|
||||
connection = psycopg2.connect(host='localhost', dbname='breweries', user='postgres', password='Q1w2e3r4t5')
|
||||
cursor=connection.cursor()
|
||||
create = """ create table Information
|
||||
(id primary key int, Name varchar(100), Place varchar(150), Sorts varchar(15), AmountOfRatings varchar(25),
|
||||
(id int primary key, Name varchar(100), Place varchar(150), Sorts varchar(15), AmountOfRatings varchar(25),
|
||||
Rating varchar(10), ImageLink varchar(150));"""
|
||||
cursor.execute(create)
|
||||
connection.commit()
|
||||
@@ -40,4 +40,4 @@ for i in range(20):
|
||||
cursor.execute('select * from Information')
|
||||
print(cursor.fetchall())
|
||||
cursor.close()
|
||||
connection.close()
|
||||
connection.close()
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium.webdriver import Chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
import psycopg2
|
||||
import wget
|
||||
import time
|
||||
|
||||
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
|
||||
cursor = connection.cursor()
|
||||
|
||||
|
||||
|
||||
s = Service('C:/Users/rusta/OneDrive/Рабочий стол/ИНФА/инфа 2 сем/driver/chromedriver.exe')
|
||||
browser = webdriver.Chrome(service=s)
|
||||
browser.get('https://www.kp.ru/expert/elektronika/luchshie-noutbuki/')
|
||||
time.sleep (10)
|
||||
html_text = browser.page_source
|
||||
soup = BeautifulSoup(html_text, 'lxml')
|
||||
|
||||
creat_table="""create table notes
|
||||
(id serial primary key, name varchar(150),
|
||||
scr varchar(150))"""
|
||||
cursor.execute(creat_table)
|
||||
connection.commit()
|
||||
|
||||
|
||||
names= soup.find_all('h3', class_="wp-block-heading")
|
||||
pictures = soup.find_all('figure', class_="wp-block-image size-full")
|
||||
print(len(names))
|
||||
for i in range(len(names)):
|
||||
url = pictures[i].find('img')['src']
|
||||
filename = f"C:\\Users\\rusta\\OneDrive\\Рабочий стол\\pictures\\{i}.jpg"
|
||||
wget.download(url, filename)
|
||||
|
||||
insert_qwery = """INSERT INTO public.notes(name, scr)
|
||||
VALUES( %s, %s, %s);"""
|
||||
record_to_insert = (names[i].text, filename)
|
||||
cursor.execute(insert_qwery, record_to_insert)
|
||||
connection.commit()
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
@@ -1,5 +1,5 @@
|
||||
import psycopg2
|
||||
import wget
|
||||
import psycopg2
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
@@ -23,9 +23,9 @@ browser.get('https://www.hellride.ru/catalog/zapchasti-dlya-tryukovyh-samokatov/
|
||||
html_code = browser.page_source
|
||||
soup = BeautifulSoup(html_code, 'lxml')
|
||||
|
||||
name = soup.find_all('span', class_='product-card__title')
|
||||
price = soup.find_all('span', class_='product-card__price')
|
||||
picture = soup.find_all('img', class_='product-slider__slide-img swiper-lazy swiper-lazy-loaded')
|
||||
name = soup.find_all(attrs={"class": "product-card__title"})
|
||||
price = soup.find_all(attrs={"class": "product-card__price"})
|
||||
picture = soup.find_all(attrs={"class": "product-slider__slide-img swiper-lazy swiper-lazy-loaded"})
|
||||
#for prices, names in zip(price, name,):
|
||||
#print(f" название {names.text} ; цена: {prices.text} ")
|
||||
for i in range(len(name)):
|
||||
@@ -42,4 +42,4 @@ for i in range(len(name)):
|
||||
|
||||
cursor.close()
|
||||
|
||||
connection.close()
|
||||
connection.close()
|
||||