Пример #1
0
    def save_product(self, product):
        link = product.find("a", {"class": "product"}).get("href")
        image = product.find("img").get("src")
        try:
            site_product_id = link.split("?productId=xlsImpprod")[1]
        except IndexError:
            site_product_id = link.split("productId=")[1]
        brand = product.find("h4", {"class": "prod-title"}).text.strip()
        item_name = product.find("p", {"class": "prod-desc"}).text.strip()
        item_name = item_name.replace("Online Only ", "")
        try:
            price = product.find("span", {"class": "regPrice"})
        except AttributeError:
            price = product.find("span", {"class": "pro-new-price"})
        if price is not None:
            price = WebFunctions.only_digits(price.text)

        product = Product(site_name="ulta",
                          link=link,
                          image=image,
                          site_product_id=site_product_id,
                          brand=brand,
                          item_name=item_name,
                          price=price)
        product.add_product(self.database)
Пример #2
0
 def save_product(self, product):
     link = product.find("a").get("href")
     image = product.find("img").get("src")
     site_product_id = product.find("button", {
         "data-comp": "ProductQuicklook"
     }).get("data-sku-number")
     brand = product.find("span", {"data-at": "sku_item_brand"}).text
     item_name = product.find("span", {"data-at": "sku_item_name"}).text
     price = WebFunctions.only_digits(
         product.find("span", {
             "data-at": "sku_item_price_list"
         }).text)
     product = Product(site_name="sephora",
                       link=link,
                       image=image,
                       site_product_id=site_product_id,
                       brand=brand,
                       item_name=item_name,
                       price=price)
     product.add_product(self.database)