Merge remote-tracking branch 'origin/master'

This commit is contained in:
13danny13
2023-04-05 11:48:58 +03:00
11 changed files with 251 additions and 23 deletions
+14 -8
View File
@@ -4,9 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<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" />
</list>
<list default="true" id="e5615680-c090-497d-a104-1337ed85f850" name="Changes" comment="Дз парсинг" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -20,7 +18,7 @@
</option>
</component>
<component name="Git.Rebase.Settings">
<option name="NEW_BASE" value="master" />
<option name="NEW_BASE" value="origin/master" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -37,7 +35,7 @@
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"last_opened_file_path": "C:/Users/71332/PycharmProjects/c22712"
"last_opened_file_path": "C:/Users/Honor/c22712"
}
}]]></component>
<component name="RunManager" selected="Python.zaparsil">
@@ -142,7 +140,14 @@
<option name="project" value="LOCAL" />
<updated>1679839777822</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="Дз парсинг">
<created>1680206771744</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1680206771744</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -162,14 +167,15 @@
<component name="VcsManagerConfiguration">
<MESSAGE value="Первый коммит" />
<MESSAGE value="parser" />
<option name="LAST_COMMIT_MESSAGE" value="parser" />
<MESSAGE value="Дз парсинг" />
<option name="LAST_COMMIT_MESSAGE" value="Дз парсинг" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>8</line>
<line>5</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
+44
View File
@@ -0,0 +1,44 @@
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from time import sleep
import psycopg2
s = Service("C:\Driver\chromedriver.exe")
browser = webdriver.Chrome(service=s)
browser.get("https://drivenew.ru/layfkhaki/besplatno/top-10-vinodelcheskikh-khozyaystv-krasnodarskogo-kraya/")
sleep(1)
html_text = browser.page_source
soup = BeautifulSoup(html_text, "lxml")
name = soup.find_all("h2")
contacts = soup.find_all("div", class_="article-info")
address = []
number = []
for element in contacts:
a = element.find_all("p")[1]
n = element.find_all("p")[2]
address.append(a)
number.append(n)
pic = soup.find("div", class_="white-bg white-bg-text box-15-new").find_all("img")
picture = []
url = "https://drivenew.ru"
for i in pic:
p = url + i.attrs.get("src")
picture.append(p)
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
cursor = connection.cursor()
create = """create table Distilleries
(id serial primary key , Name varchar(100), Place varchar(200), Contacts varchar(100), ImageLink varchar(80));"""
cursor.execute(create)
connection.commit()
for j in range(10):
qwery = f"insert into public.distilleries(Name, Place, Contacts, ImageLink) values('{name[j].text.strip()}', '{address[j].text.strip()}', '{number[j].text.strip()}', '{picture[j]}')"
cursor.execute(qwery)
connection.commit()
cursor.execute('select * from Distilleries')
print(cursor.fetchall())
cursor.close()
connection.close()
+44
View File
@@ -0,0 +1,44 @@
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from time import sleep
import psycopg2
s = Service("C:\Driver\chromedriver.exe")
browser = webdriver.Chrome(service=s)
browser.get("https://drivenew.ru/layfkhaki/besplatno/top-10-vinodelcheskikh-khozyaystv-krasnodarskogo-kraya/")
sleep(1)
html_text = browser.page_source
soup = BeautifulSoup(html_text, "lxml")
name = soup.find_all("h2")
contacts = soup.find_all("div", class_="article-info")
address = []
number = []
for element in contacts:
a = element.find_all("p")[1]
n = element.find_all("p")[2]
address.append(a)
number.append(n)
pic = soup.find("div", class_="white-bg white-bg-text box-15-new").find_all("img")
picture = []
url = "https://drivenew.ru"
for i in pic:
p = url + i.attrs.get("src")
picture.append(p)
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
cursor = connection.cursor()
create = """create table Distilleries
(id serial primary key , Name varchar(100), Place varchar(200), Contacts varchar(100), ImageLink varchar(80));"""
cursor.execute(create)
connection.commit()
for j in range(10):
qwery = f"insert into public.distilleries(Name, Place, Contacts, ImageLink) values('{name[j].text.strip()}', '{address[j].text.strip()}', '{number[j].text.strip()}', '{picture[j]}')"
cursor.execute(qwery)
connection.commit()
cursor.execute('select * from Distilleries')
print(cursor.fetchall())
cursor.close()
connection.close()
-1
View File
@@ -1 +0,0 @@
Hello World!
-9
View File
@@ -1,9 +0,0 @@
# Diana Gasanova
import requests
from bs4 import BeautifulSoup as bs
URL = "https://www.kinopoisk.ru/lists/movies/top-250-2020/"
r = requests.get(URL, timeout=10)
soup = bs(r.text, "html.parser")
films = soup.find_all(attrs={"class": "styles_mainTitle__IFQyZ styles_activeMovieTittle__kJdJj"})
for film in films:
print(film.text)
+29
View File
@@ -0,0 +1,29 @@
# парсер к полусему 8 неделя
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from wget import download
import psycopg2 as psyc
# s = Service("chromedriver") на Ubuntu можно не указывать путь до драйвера :)
URL = "https://proskateshop.ru/skejtbordy/?utm_source=yandex&utm_medium=cpc&utm_campaign=cn%7Cskeyty_gz-1%7Ccid%7C51517250%7Csearch&utm_content=gid%7C4180310153%7Caid%7C8980588780%7C20506942844_20506942844%7Cmain&utm_term=%D0%9F%D0%B5%D0%BD%D0%BD%D0%B8%20%D0%B1%D0%BE%D1%80%D0%B4%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C&etext=2202.N39xvihj0F0Od_d4etv_6nh36sdlRP-T26wHLuCJfjo_JZtVI5O7HY5f8FOJnzuLZXB6eWZoZnp2dG1laHBlcA.aceac50a24e4832d82874cd59ca1f9a315d9b351&_openstat=ZGlyZWN0LnlhbmRleC5ydTs1MTUxNzI1MDs4OTgwNTg4NzgwO3lhbmRleC5ydTpndWFyYW50ZWU&yclid=1445113833197462400"
brow = webdriver.Chrome()
brow.get(URL)
html = brow.page_source
soup = BeautifulSoup(html, "lxml")
penny = soup.find_all(attrs={"class": "product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-6"})
with psyc.connect(dbname="db_for_parse", user="dialuna") as conn:
with conn.cursor() as cursor:
for i, product in enumerate(penny[1:]):
image_link = product.find("img").attrs.get("src")
image_name = product.find("img").attrs.get("alt")
price = product.find("p", attrs={"class": "price"}).text.strip()
cursor.execute(f"""insert into test(link, name, price, file)
values ('{image_link}', '{image_name}', '{price}', 'images/{i}.jpg')""")
conn.commit()
@@ -0,0 +1,43 @@
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import psycopg2
from time import sleep
s = Service("C:\data\chromedriver.exe")
browser = webdriver.Chrome(service=s)
browser.get('https://untappd.com/brewery/top_rated')
sleep(1)
html_text=browser.page_source
soup = BeautifulSoup(html_text, 'lxml')
ratings = soup.find_all('div', class_='beer-item')
item = []
for i in ratings:
c = i.text
c = c.split('\n')
for k in c:
if k == '':
c.pop(c.index(k))
d = i.find('img').get('src')
c.append(d)
item.append(c)
item.pop(3)
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),
Rating varchar(10), ImageLink varchar(150));"""
cursor.execute(create)
connection.commit()
for i in range(20):
insert_qwery="""INSERT INTO public.Information(id,Name, Place, Sorts, AmountOfRatings, Rating, ImageLink) VALUES
( '"""+str(i+1)+"""', '"""+item[i][0]+"""', '"""+item[i][1]+"""', '"""+item[i][2]+"""', '"""+item[i][3]+"""',
'"""+item[i][9]+"""', '"""+item[i][13]+"""');""";
cursor.execute(insert_qwery)
connection.commit()
cursor.execute('select * from Information')
print(cursor.fetchall())
cursor.close()
connection.close()
+41
View File
@@ -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()
+15
View File
@@ -0,0 +1,15 @@
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service('D:\data\chromedriver.exe')
browser = webdriver.Chrome(service=s)
browser.get('https://www.kfc.ru/')
html_text = browser.page_source
soup = BeautifulSoup(html_text, 'lxml')
prices = soup.find_all(attrs={"class": "GFmMCzZoYv"})
titles = soup.find_all(attrs={"class": "_14ZQf5wtqx c-description"})
for price, title in zip(prices, titles):
print(f" название {title.text} ; цена: {price.text}")
+15
View File
@@ -0,0 +1,15 @@
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
s = Service('C:/Users/rusta/OneDrive/Рабочий стол/ИНФА/инфа 2 сем/driver/chromedriver.exe')
browser = webdriver.Chrome(service=s)
browser.get('https://lafoy.ru/modnye-muzhskie-strizhki-2023-3052/')
time.sleep (10)
html_text = browser.page_source
soup = BeautifulSoup(html_text, 'lxml')
haircuts = soup.find_all('h2', class_='tm8 post__title')
for i in range(0, 30):
print(haircuts[i].text)
+6 -5
View File
@@ -8,7 +8,7 @@ connection = psycopg2.connect(host='localhost', dbname='postgres',
cursor = connection.cursor()
cr_qwery = """ create table avito
cr_qwery = """ create table parser
(id serial primary key,
name varchar(60),
price varchar(15),
@@ -17,8 +17,8 @@ cr_qwery = """ create table avito
cursor.execute(cr_qwery)
connection.commit()
driver = Service('C:\Desktop\exe\chromedriver.exe')
browser = webdriver.Chrome(service=driver)
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_code = browser.page_source
soup = BeautifulSoup(html_code, 'lxml')
@@ -26,9 +26,10 @@ 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')
#for prices, names in zip(price, name,):
#print(f" название {names.text} ; цена: {prices.text} ")
for i in range(len(name)):
url = picture[i].find('img').attrs['src']
url = picture[i].attrs['src']
filename = f"C:\\Users\\Михаил\PycharmProjects\pythonProject8\\venv\Pictures\{i}.jpg"
wget.download(url, filename)
ins_qwery = f"""insert into public.Parser(name, price, picture)