mirror of
https://github.com/KUlishevgeniy/c22712.git
synced 2026-09-24 08:00:22 +00:00
Дз парсинг
This commit is contained in:
Generated
+7
-7
@@ -4,7 +4,7 @@
|
|||||||
<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="parser">
|
<list default="true" id="e5615680-c090-497d-a104-1337ed85f850" name="Changes" comment="Первый коммит">
|
||||||
<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" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="Git.Rebase.Settings">
|
<component name="Git.Rebase.Settings">
|
||||||
<option name="NEW_BASE" value="master" />
|
<option name="NEW_BASE" value="origin/master" />
|
||||||
</component>
|
</component>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
@@ -35,11 +35,11 @@
|
|||||||
<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"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"last_opened_file_path": "C:/Users/71332/PycharmProjects/c22712"
|
"last_opened_file_path": "C:/Users/71332/PycharmProjects/c22712"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager" selected="Python.zaparsil">
|
<component name="RunManager" selected="Python.zaparsil">
|
||||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
<module name="22712" />
|
<module name="22712" />
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<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>
|
<line>5</line>
|
||||||
<option name="timeStamp" value="1" />
|
<option name="timeStamp" value="1" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|
||||||
|
create_table = """ create table dresses
|
||||||
|
(id serial primary key, name varchar(200), sale varchar(50), price varchar(50), info varchar(50), picture varchar(200))"""
|
||||||
|
|
||||||
|
cursor.execute(create_table)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
driver = Service('D:\data\chromedriver.exe')
|
||||||
|
browser = webdriver.Chrome(service=driver)
|
||||||
|
browser.get('https://www.ozon.ru/category/platya-zhenskie-7502/')
|
||||||
|
html_code = browser.page_source
|
||||||
|
soup = BeautifulSoup(html_code, 'lxml')
|
||||||
|
|
||||||
|
name = soup.find_all('span', class_="m2e e3m m3e m5e tsBodyL k7l l7k")
|
||||||
|
sale = soup.find_all('div', class_="eg1 g3e")
|
||||||
|
price = soup.find_all('span', class_="a2a-a2")
|
||||||
|
info = soup.find_all('span', class_="je4")
|
||||||
|
picture = soup.find_all('div', class_="k1m")
|
||||||
|
|
||||||
|
for i in range(20):
|
||||||
|
url = picture[i].find('img').attrs['src']
|
||||||
|
file_name = f"C:\\Users\\Honor\\Desktop\\учеба\\прога\\pictures\\{i}.jpg"
|
||||||
|
wget.download(url, file_name)
|
||||||
|
ins_table = f"""insert into public.dresses(name, sale, price, info, picture) values ('{name[i].text}', '{sale[i].text}', '{price[i].text}', '{info[i].text}', '{file_name}')"""
|
||||||
|
cursor.execute(ins_table)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
|
connection.close()
|
||||||
Reference in New Issue
Block a user