47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import sys
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
from currency import Currency
|
|
from item import Item
|
|
|
|
items = []
|
|
|
|
bank = Currency("JPY")
|
|
if not bank.status:
|
|
print("Not correct currency code")
|
|
sys.exit()
|
|
|
|
url = "https://www.fint-shop.com/c/all/bag?top_category"
|
|
|
|
response = requests.get(url)
|
|
response.raise_for_status()
|
|
|
|
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
products = soup.find_all("article", class_="fs-c-productList__list__item")
|
|
category_name = soup.find_all("li", class_="fs-c-breadcrumb__listItem")[1].get_text(
|
|
strip=True
|
|
)
|
|
print(category_name)
|
|
for product in products:
|
|
product_name = product.find("span", class_="fs-c-productName__name").get_text(
|
|
strip=True
|
|
)
|
|
|
|
price = int(
|
|
product.find("div", class_="fs-c-productPrice--listed")
|
|
.find("span", class_="fs-c-price__value")
|
|
.get_text(strip=True)
|
|
.replace(",", "")
|
|
)
|
|
product_price = round(price * (bank.rate / bank.nominal), 2)
|
|
|
|
product_photo = product.find(
|
|
"img", class_="fs-c-productListItem__image__image fs-c-productImage__image"
|
|
)["data-layzr"]
|
|
items.append(Item(product_name, "bags", product_price, product_photo))
|
|
|
|
for item in items:
|
|
print(f"Name = {item.name}, price = {item.price}")
|