Домашнее задание: Парсинг Сайта

This commit is contained in:
Dronminator
2023-02-25 20:11:24 +03:00
parent df2c5e857c
commit 7dac6bdb21
2 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project> </project>
+7 -7
View File
@@ -1,14 +1,14 @@
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
from time import sleep
s = Service("С:\DATA\ChromeDriver\chromedriver.exe") s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
browser = webdriver.Chrome(service=s) browser = webdriver.Chrome(service=s)
browser.get("https://www.kinopoisk.ru/lists/movies/top250/") browser.get("https://online.metro-cc.ru/category/sladosti-chipsy-sneki/shokolad-batonchiki?from=under_search&is_action=1")
sleep(15)
html_text = browser.page_source html_text = browser.page_source
soup = BeautifulSoup(html_text, 'lxml') soup = BeautifulSoup(html_text, 'lxml')
films = soup.find_all('div', class_="desktop-list-main-info_secondaryTitleSlot__mc0mI") products = soup.find_all('a', class_="product-card-name reset-link catalog-2-level-product-card__name style--catalog-2-level-product-card")
for film in films: prices = soup.find_all('span', class_="product-card-prices__actual color-red")
print(film.text) for product,price in zip(products, prices):
print("--------") print(f"Продукт: {product.text[3:]}Цена: {price.text}")
print("-"*100)