Beispiel #1
0
 def _enrich_deals_from_soup(self, soup, deals):
     for item in soup.findAll('article', attrs={'class': 'grille-produit'}):
         product_name = item.find('h3').text
         product_price = clean_price(
             item.find('div', attrs={
                 'itemprop': 'price'
             }).text)
         deals[product_name] = product_price
Beispiel #2
0
 def _enrich_deals_from_soup(self, soup, deals):
     for item in soup.find_all(
             'article', attrs={'itemtype': 'http://schema.org/Product'}):
         product_name = item.find('div', attrs={'class': 'summary'}).text
         product_price = clean_price(
             item.find('div', attrs={
                 'class': 'price'
             }).text)
         deals[product_name] = product_price
Beispiel #3
0
 def _enrich_deals_from_soup(self, soup, deals):
     products = soup.findAll('div', attrs={'class': re.compile('ppp-*')})
     for product in products:
         tag = product.find('div', attrs={'class': re.compile('product*')})
         brand = tag.find('span', attrs={'class': 'marque'}).text
         self.remove_all_span(tag)
         second_part = tag.find('a', attrs={'class': 'prod_txt_left'}).text
         product_name = brand + self.remove_garbage_characters(second_part)
         product_price = clean_price(
             product.find('div', attrs={
                 'class': 'price_prod_resp'
             }).text)
         deals[product_name] = product_price
Beispiel #4
0
 def _enrich_deals_from_soup(self, soup, deals):
     items = soup.find_all('li',
                           attrs={'data-ref': re.compile("[A-Za-z0-9]")})
     for item in items:
         product_name = item.find('div', attrs={
             'class': 'description'
         }).find('h2').text
         for script_section in soup.findAll('script'):
             if '.price-wrapper' in script_section.text:
                 print(script_section.prettify())
         product_price = clean_price(
             item.find('div', attrs={
                 'class': 'price_prod_resp'
             }).text)
         deals[product_name] = product_price
Beispiel #5
0
 def _enrich_deals_from_soup(self, soup, deals):
     for product in soup.find('table', attrs={
             'id': 'listing_mode_display'
     }).findAll('tr'):
         try:
             product_name = product.find('div',
                                         attrs={
                                             'class': 'product_description'
                                         }).find('a').text
             product_price = clean_price(
                 product.find('td', attrs={
                     'class': 'btn_price_wrapper'
                 }).find('b').text)
             deals[product_name] = product_price
         except Exception as exception:
             pass
Beispiel #6
0
 def _enrich_deals_from_soup(self, soup: bs4.BeautifulSoup, deals):
     for item in soup.find_all("script"):
         if "ecommerce" in item.text:
             for gpu in [x for x in item.text.split("{") if "name" in x]:
                 product_name = None
                 product_price = None
                 # Look for name and price
                 for token in gpu.strip().split(","):
                     if "name" in token:
                         product_name = token.split(":")[1].replace(
                             "'", "").strip()
                     elif "price" in token:
                         product_price = token.split(":")[1]
                 if product_name and product_price:
                     deals[product_name] = clean_price(product_price)
                 else:
                     logger.warning(
                         f"Product name [{product_name}] and price [{product_price}] seem not available."
                     )
Beispiel #7
0
 def _enrich_deals_from_soup(self, soup, deals):
     for product in soup.findAll('div', attrs={'class': 'pcontent'}):
         product_name = product.find('div', attrs={'class': 'pname'}).text
         product_price = product.find('div', attrs={'class': 'pprice'}).text
         deals[product_name] = clean_price(product_price)
Beispiel #8
0
 def test_case_5(self):
     self.assertEqual("1167.83", clean_price('€ 1.167,83*'))
Beispiel #9
0
 def test_case_4(self):
     self.assertEqual(self.reference_price, clean_price('4 22€45'))
Beispiel #10
0
 def test_case_2(self):
     self.assertEqual(self.reference_price,
                      clean_price('   ---   422,45   €*'))
Beispiel #11
0
 def test_case_1(self):
     self.assertEqual(self.reference_price,
                      clean_price('      422.45   €*'))
Beispiel #12
0
 def _enrich_deals_from_soup(self, soup, deals):
     for product in soup.findAll("div", attrs={"class": "price-and-status d-flex flex-wrap align-items-center"}):
         product_name = product.find("a", attrs={"itemprop": "url"}).text
         product_price = product.find("span", attrs={"class": "price product-price"}).text
         deals[product_name] = clean_price(product_price)