mirror of
https://github.com/KUlishevgeniy/c22712.git
synced 2026-09-24 08:00:22 +00:00
Merge branch 'master' of github.com:KUlishevgeniy/c22712
This commit is contained in:
Generated
+35
-43
@@ -4,9 +4,8 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e5615680-c090-497d-a104-1337ed85f850" name="Changes" comment="ганьг или баньг СХС">
|
<list default="true" id="e5615680-c090-497d-a104-1337ed85f850" name="Changes" comment="parser">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -36,39 +35,12 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"last_opened_file_path": "C:/Users/rusta/c22712",
|
"last_opened_file_path": "C:/Users/71332/PycharmProjects/c22712"
|
||||||
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
|
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RunManager" selected="Python.zaparsil">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
|
||||||
<recent name="C:\Users\rusta\c22712" />
|
|
||||||
</key>
|
|
||||||
</component>
|
|
||||||
<component name="RunManager" selected="Python.main">
|
|
||||||
<configuration name="1page1win" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="22712" />
|
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
|
||||||
<option name="PARENT_ENVS" value="true" />
|
|
||||||
<envs>
|
|
||||||
<env name="PYTHONUNBUFFERED" value="1" />
|
|
||||||
</envs>
|
|
||||||
<option name="SDK_HOME" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../OneDrive/Рабочий стол/парсинг" />
|
|
||||||
<option name="IS_MODULE_SDK" value="false" />
|
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
||||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../OneDrive/Рабочий стол/парсинг/1page1win.py" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
|
||||||
<option name="EMULATE_TERMINAL" value="false" />
|
|
||||||
<option name="MODULE_MODE" value="false" />
|
|
||||||
<option name="REDIRECT_INPUT" value="false" />
|
|
||||||
<option name="INPUT_FILE" value="" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
<module name="22712" />
|
<module name="22712" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
@@ -76,10 +48,9 @@
|
|||||||
<envs>
|
<envs>
|
||||||
<env name="PYTHONUNBUFFERED" value="1" />
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
</envs>
|
</envs>
|
||||||
<option name="SDK_HOME" value="C:\Users\rusta\PycharmProjects\pythonProject\venv\Scripts\python.exe" />
|
<option name="SDK_HOME" value="" />
|
||||||
<option name="SDK_NAME" value="Python 3.11 (pythonProject)" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
<option name="IS_MODULE_SDK" value="false" />
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||||
@@ -92,9 +63,30 @@
|
|||||||
<option name="INPUT_FILE" value="" />
|
<option name="INPUT_FILE" value="" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="zaparsil" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="22712" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Задания/task1/Sukhanov" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/Задания/task1/Sukhanov/zaparsil.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Python.1page1win" />
|
<item itemvalue="Python.zaparsil" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
@@ -143,12 +135,12 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1676934066947</updated>
|
<updated>1676934066947</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00006" summary="ганьг или баньг СХС">
|
<task id="LOCAL-00006" summary="parser">
|
||||||
<created>1678906921509</created>
|
<created>1679839777822</created>
|
||||||
<option name="number" value="00006" />
|
<option name="number" value="00006" />
|
||||||
<option name="presentableId" value="LOCAL-00006" />
|
<option name="presentableId" value="LOCAL-00006" />
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1678906921509</updated>
|
<updated>1679839777822</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="7" />
|
<option name="localTasksCounter" value="7" />
|
||||||
<servers />
|
<servers />
|
||||||
@@ -170,14 +162,14 @@
|
|||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="Первый коммит" />
|
<MESSAGE value="Первый коммит" />
|
||||||
<MESSAGE value="parser" />
|
<MESSAGE value="parser" />
|
||||||
<MESSAGE value="ганьг или баньг СХС" />
|
<option name="LAST_COMMIT_MESSAGE" value="parser" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="ганьг или баньг СХС" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
<url>file://$PROJECT_DIR$/main.py</url>
|
<url>file://$PROJECT_DIR$/main.py</url>
|
||||||
|
<line>8</line>
|
||||||
<option name="timeStamp" value="1" />
|
<option name="timeStamp" value="1" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ 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)
|
|
||||||
wget.download(url, 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}')"""
|
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)
|
cursor.execute(ins_qwery)
|
||||||
@@ -39,4 +38,4 @@ for i in range(15):
|
|||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
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()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#made by dialuna (or just Diana Gasanova) <3
|
# Diana Gasanova
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as bs
|
from bs4 import BeautifulSoup as bs
|
||||||
URL = "https://www.kinopoisk.ru/lists/movies/top-250-2020/"
|
URL = "https://www.kinopoisk.ru/lists/movies/top-250-2020/"
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
from wget import download
|
||||||
|
import psycopg2
|
||||||
|
connection = psycopg2.connect(host='localhost', dbname='dbdata',
|
||||||
|
user='postgres', password='Q1w2e3r4')
|
||||||
|
cursor=connection.cursor()
|
||||||
|
s = Service('C:\\Users\\Dasha\\Desktop\\Progect\\chromedriver.exe')
|
||||||
|
browser = webdriver.Chrome(service=s)
|
||||||
|
url = 'https://www.tretyakovgallery.ru/'
|
||||||
|
browser.get(url)
|
||||||
|
html_text=browser.page_source
|
||||||
|
soup = BeautifulSoup(html_text, 'lxml')
|
||||||
|
products = soup.find_all(attrs={"class": "building-item"})
|
||||||
|
for i, product in enumerate(products):
|
||||||
|
link = product.find("img").attrs.get("src")
|
||||||
|
tag = product.find("strong")
|
||||||
|
if tag is not None:
|
||||||
|
download(url + link, f"img\\{i}.jpg")
|
||||||
|
cursor.execute(f"""INSERT INTO public.parsing(name, link)
|
||||||
|
VALUES
|
||||||
|
( '{tag.text}', '{url + link}')""")
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import psycopg2
|
||||||
|
import wget
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
import time
|
||||||
|
i = 1
|
||||||
|
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
|
||||||
|
browser = webdriver.Chrome(service=s)
|
||||||
|
browser.get("https://www.mvideo.ru/noutbuki-planshety-komputery-8/noutbuki-118?from=under_search")
|
||||||
|
height = browser.execute_script("return document.body.scrollHeight")
|
||||||
|
time.sleep(4)
|
||||||
|
while 900*i < height:
|
||||||
|
height = browser.execute_script("return document.body.scrollHeight")
|
||||||
|
browser.execute_script(f"window.scrollTo(0,{900*i})")
|
||||||
|
time.sleep(1)
|
||||||
|
i+=1
|
||||||
|
html_text = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_text, 'lxml')
|
||||||
|
productst = soup.find_all('a', class_="product-title__text")
|
||||||
|
pricest = soup.find_all('span', class_="price__main-value")
|
||||||
|
features = soup.find_all('ul', class_="product-feature-list product-feature-list--undefined")
|
||||||
|
pictures = soup.find_all('img', class_="product-picture__img product-picture__img--list")
|
||||||
|
products, prices, diagonals, resolutions, CPUs, RAMs, Graphics_controllers, Volumes = [],[],[],[],[],[],[],[]
|
||||||
|
for i in range(len(productst)):
|
||||||
|
products.append(productst[i].text.strip())
|
||||||
|
prices.append(pricest[i].text.replace("\xa0", "").strip())
|
||||||
|
for feature in features:
|
||||||
|
u = feature.text
|
||||||
|
diagonals.append(u[20:u.find("\"",20)+1])
|
||||||
|
resolutions.append(u[u.find("\"",20)+2:u.find(".", 23)+1])
|
||||||
|
CPUs.append(u[u.find("Процессор",20)+9:u.find("ГГц",20)+3].replace("\xa0",""))
|
||||||
|
RAMs.append(" ".join(u[u.find("(RAM)",20)+5:u.find("Графический контроллер")].split()))
|
||||||
|
Graphics_controllers.append(u[u.find("Графический контроллер")+22:u.rfind("Объем")-2])
|
||||||
|
Volumes.append(u[u.rfind("Объем")+6:].replace("\xa0", "").strip())
|
||||||
|
for i in range(len(Volumes)):
|
||||||
|
u = Volumes[i]
|
||||||
|
if u.rfind("D")!=-1: Volumes[i] = u[:u.rfind("D")+1]+ " " + u[u.rfind("D")+1:]
|
||||||
|
else: Volumes[i] = u[:u.rfind("С")+1]+ " " + u[u.rfind("С")+1:]
|
||||||
|
connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
insert = """CREATE TABLE public.laptops(
|
||||||
|
id serial primary key,
|
||||||
|
product varchar(100),
|
||||||
|
price varchar(15),
|
||||||
|
diagonal varchar(5),
|
||||||
|
resolution varchar(20),
|
||||||
|
CPU varchar(50),
|
||||||
|
RAM varchar(10),
|
||||||
|
Graphics_Controller varchar(40),
|
||||||
|
Volume varchar(25),
|
||||||
|
src varchar(100)
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
cursor.execute(insert)
|
||||||
|
connection.commit()
|
||||||
|
for i in range(len(products)):
|
||||||
|
url = "https://"+pictures[i]['src']
|
||||||
|
filename = f"C:\DATA\Images\{i+1}.jpg"
|
||||||
|
wget.download(url, filename)
|
||||||
|
insert = f"""INSERT INTO public.laptops(
|
||||||
|
product, price, diagonal, resolution, CPU, RAM, Graphics_Controller, Volume, src)
|
||||||
|
VALUES
|
||||||
|
('{products[i]}', '{prices[i]}', '{diagonals[i]}', '{resolutions[i]}', '{CPUs[i]}', '{RAMs[i]}', '{Graphics_controllers[i]}', '{Volumes[i]}', '{filename}');"""
|
||||||
|
cursor.execute(insert)
|
||||||
|
connection.commit()
|
||||||
|
cursor.execute("select * from laptops")
|
||||||
|
print("Результат", cursor.fetchall())
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import psycopg2
|
||||||
|
import wget
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
|
||||||
|
browser = webdriver.Chrome(service=s)
|
||||||
|
browser.get("https://online.metro-cc.ru/virtual/assortiment_rioba-4887?from=under_search&page=2")
|
||||||
|
html_text = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_text, 'lxml')
|
||||||
|
productst = soup.find_all('span', class_="product-card-name__text")
|
||||||
|
pricest = soup.find_all('span', class_="product-price__sum-rubles")
|
||||||
|
pictures = soup.find_all('img', class_="product-card-photo__image")
|
||||||
|
connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
products, prices = [], []
|
||||||
|
for i in range(len(productst)):
|
||||||
|
products.append(productst[i].text.replace("\n", "").strip())
|
||||||
|
prices.append(pricest[i].text+" Р/шт")
|
||||||
|
insert = """CREATE TABLE public.Chocolate(
|
||||||
|
id serial primary key,
|
||||||
|
product varchar(100),
|
||||||
|
price varchar(25),
|
||||||
|
src varchar(50)
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
cursor.execute(insert)
|
||||||
|
connection.commit()
|
||||||
|
for i in range(len(products)):
|
||||||
|
url = pictures[i]['src']
|
||||||
|
filename = f"C:\DATA\Images2\{i+1}.jpg"
|
||||||
|
wget.download(url, filename)
|
||||||
|
insert = f"""INSERT INTO public.Chocolate(
|
||||||
|
product, price, src)
|
||||||
|
VALUES
|
||||||
|
('{products[i]}', '{prices[i]}', '{filename}');"""
|
||||||
|
cursor.execute(insert)
|
||||||
|
connection.commit()
|
||||||
|
cursor.execute("select * from Chocolate")
|
||||||
|
print("Результат", cursor.fetchall())
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
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='dbdata', user='postgres', password='Q1w2e3r4')
|
||||||
|
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
cr_qwery = """ create table Parser
|
||||||
|
(id serial primary key, name varchar(100), sale varchar(30), price varchar(10), rate varchar(10), picture varchar(100))"""
|
||||||
|
|
||||||
|
#cursor.execute(cr_qwery)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
driver = Service('D:\GOGdriver\chromedriver.exe')
|
||||||
|
browser = webdriver.Chrome(service=driver)
|
||||||
|
browser.get('https://www.perekrestok.ru/cat/promo/10')
|
||||||
|
html_code = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_code, 'lxml')
|
||||||
|
|
||||||
|
name = soup.find_all('div', class_="product-card__title")
|
||||||
|
sale = soup.find_all('div', class_="sc-kYrlTI ciSrDA product-card__badge")
|
||||||
|
price = soup.find_all('div', class_="price-new")
|
||||||
|
rate = soup.find_all('div', class_="rating-value")
|
||||||
|
picture = soup.find_all('div', class_="product-card__image-wrapper")
|
||||||
|
|
||||||
|
for i in range(15):
|
||||||
|
url = picture[i].find('img').attrs['src']
|
||||||
|
filename = f"C:\\Users\\71332\PycharmProjects\pythonProject1\\venv\Pictures\{i}.jpg"
|
||||||
|
wget.download(url, filename)
|
||||||
|
ins_qwery = f"""insert into public.Parser(name, sale, price, rate, picture) values ('{name[i].text}', '{sale[i].text}', '{price[i].text}', '{rate[i].text}', '{filename}')"""
|
||||||
|
cursor.execute(ins_qwery)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
|
connection.close()
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
|
||||||
|
driver = Service('D:\GOGdriver\chromedriver.exe')
|
||||||
|
browser = webdriver.Chrome(service=driver)
|
||||||
|
browser.get('https://www.kinopoisk.ru/lists/movies/popular-films/')
|
||||||
|
html_code = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_code, 'lxml')
|
||||||
|
name = soup.find_all('div', class_="desktop-list-main-info_secondaryTitleSlot__mc0mI")
|
||||||
|
|
||||||
|
print(soup)
|
||||||
|
print(name)
|
||||||
|
|
||||||
|
for i in name:
|
||||||
|
print(i.text)
|
||||||
@@ -1,12 +1,42 @@
|
|||||||
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 psycopg2
|
||||||
|
import wget
|
||||||
|
|
||||||
|
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
s = Service('D:\Games\data\chromedriver.exe')
|
s = Service('D:\Games\data\chromedriver.exe')
|
||||||
browser = webdriver.Chrome(service=s)
|
browser = webdriver.Chrome(service=s)
|
||||||
browser.get('https://www.volkswagen.ru/polo/')
|
browser.get('https://www.volkswagen.ru/polo/')
|
||||||
html_text = browser.page_source
|
html_text = browser.page_source
|
||||||
soup = BeautifulSoup(html_text, 'lxml')
|
soup = BeautifulSoup(html_text, 'lxml')
|
||||||
|
|
||||||
|
creat_table = """ create table Cars_volks
|
||||||
|
(id serial primary key, car_name varchar(20),
|
||||||
|
price varchar(15), adress varchar(300),
|
||||||
|
scr varchar(150)) """
|
||||||
|
#cursor.execute(creat_table)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
car_names = soup.find_all('div', class_='avn001-2_name')
|
car_names = soup.find_all('div', class_='avn001-2_name')
|
||||||
prices = soup.find_all('div', class_='avn001-2_price-container')
|
prices = soup.find_all('div', class_='avn001-2_price-container')
|
||||||
for car_name, price in zip(car_names, prices):
|
adresses = soup.find_all('div', class_='avn001-2_dealer-link__text')
|
||||||
print(f"Название машины:{car_name.text} | Цена: {price.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(len(car_names)):
|
||||||
|
url = pictures[i].find('img').attrs['src']
|
||||||
|
filename = f"c22712\\Задания\\task1\\nikitin\\img\\{i}.jpg"
|
||||||
|
# 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()
|
||||||
@@ -1 +1 @@
|
|||||||
def print_hi(' hello')
|
абоба
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
|
||||||
|
s = Service('C:\Desktop\exe\chromedriver.exe')
|
||||||
|
browser = webdriver.Chrome(service=s)
|
||||||
|
browser.get('https://www.hellride.ru/catalog/zapchasti-dlya-tryukovyh-samokatov/deki')
|
||||||
|
html_text = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_text, 'lxml')
|
||||||
|
prices = soup.find_all(attrs={"class": "product-card__price"})
|
||||||
|
titles = soup.find_all(attrs={"class": "product-card__title"})
|
||||||
|
|
||||||
|
for price, title in zip(prices, titles):
|
||||||
|
print(f" название {title.text} ; цена: {price.text}")
|
||||||
Reference in New Issue
Block a user