class DiaMarketScraping(SuperMarketScraping): """Class represents DiaMarketScraping fields: market, logger & url""" market: str = "DIA" logger: Log = Log().get_logger(__name__) url: str = "https://diaonline.supermercadosdia.com.ar/especial-ofertas" def get_products_from_markets(self) -> list: product_list: list[SupermarketProduct] = [] response = get_response_by_url(url=self.url) self.logger.info( f"*********************[ SCRAPING STARTED ]*********************") for market_value in response.find_all("li"): try: product_name, product_price = get_title_product_and_product_value( supermarket=self.market, value=market_value) new_product: SupermarketProduct = SupermarketProductSchema( ).load({ "market": self.market, "product": product_name, "price": product_price, }) product_list.append(new_product) self.logger.info( f'* The product was correctly extracted: "{new_product.__str__()}"' ) except: pass self.logger.info( f"*********************[ SCRAPING FINISHED ]*********************") return product_list
from schemas.cryptoCurrencyPrices_schema import CryptoCurrencyPricesSchema from model.cryptoCurrencyPrices_model import CryptoCurrencyPrices from model.cryptoCurrency_model import CryptoCurrency from datetime import datetime from log.logger import Log import requests # GLOBAL VALUES # logger = Log().getLogger(__name__) time_out = 20 def get_crypto_name_by_url(url: str) -> str: """Returns the name of the exchange in uppercase""" return url.split("/")[4].upper() def get_str_time_now() -> str: """Return the current date in String format""" return datetime.now().strftime("%H:%M:%S %d-%m-%Y") def get_str_payload(payload: dict) -> str: """Return the parameter payload in string format depending on: '/' :param payload: dict :return: str """ try: payload_str = "" for p in payload: