def _get_price(self):
     """
         <div class="col search_price responsive_secondrow">
             NT$ 920
         </div>
         -----------------------------------------------------------------
         <div class="col search_price discounted responsive_secondrow">
             <span style="color: #888888;"><strike> NT$ 398 </strike></span><br/>NT$ 358
         </div>
     """
     price_container = BSoupHandler.find_tag_by_key_value(
         soup=self.target_soup,
         tag='div',
         key='class',
         value='col search_price responsive_secondrow')
     special_price_container = BSoupHandler.find_tag_by_key_value(
         soup=self.target_soup,
         tag='div',
         key='class',
         value='col search_price discounted responsive_secondrow')
     if price_container:
         price_text = BSoupHandler.get_text(soup=price_container)
     elif special_price_container:
         price_span = BSoupHandler.find_tag(soup=special_price_container,
                                            tag_name='span')
         price_text = BSoupHandler.get_text(soup=price_span)
     else:
         price_text = None
     return price_text.strip().replace(',', '') if price_text else None
 def _get_title(self):
     """
      <span class="title">
          Grand Theft Auto V: Premium Online Edition
      </span>
     """
     title_container = BSoupHandler.find_tag_by_key_value(
         soup=self.target_soup, tag='span', key='class', value='title')
     return BSoupHandler.get_text(soup=title_container)
 def _get_search_results_amount(self, page_soup):
     """
         <div class="search_pagination_left">
             showing 1 - 25 of 2356
         </div>
     """
     search_pagination = self._get_pagination_container(page_soup=page_soup)
     amount_container = BSoupHandler.find_tag_by_key_value(
         soup=search_pagination, tag='div', key='class',
         value=STEAM.LABEL.AMOUNT_OF_RESULTS)
     amount_string = BSoupHandler.get_text(soup=amount_container)
     return DataParser.get_results_amount(amount_string) if amount_string else None
 def _get_search_pages_amount(self, page_soup):
     """
         <a class="pagebtn" href="a_link"> < </a>
         <a href="a_link"> 2 </a>
         <a href="a_link"> 3 </a>
             ...
         <a href="a_link"> 95 </a>
         <a class="pagebtn" href="a_link"> > </a>
     """
     search_pagination = self._get_pagination_container(page_soup=page_soup)
     pagination_list = BSoupHandler.find_all_tag(
         soup=search_pagination, tag_name='a')
     pagination_soup = pagination_list[-2] if pagination_list else None
     return BSoupHandler.get_text(soup=pagination_soup)
 def _get_released_date(self):
     """
     <div class="col search_released responsive_secondrow">
     13 Apr, 2015
     """
     released_date_container = BSoupHandler.find_tag_by_key_value(
         soup=self.target_soup,
         tag='div',
         key='class',
         value='col search_released responsive_secondrow')
     released_date = BSoupHandler.get_text(soup=released_date_container)
     if not released_date:
         return None
     released_date_list = released_date.split(' ')
     try:
         if released_date_list == 3 and released_date_list[0].isdigit(
         ) and (released_date_list[1]) > 3:
             return datetime.strptime(released_date, '%d %B, %Y').date()
         if released_date_list == 3 and released_date_list[0].isdigit(
         ) and (released_date_list[1]) == 3:
             return datetime.strptime(released_date, '%d %b, %Y').date()
         elif released_date_list == 3 and released_date_list[1].isdigit(
         ) and (released_date_list[0]) > 3:
             return datetime.strptime(released_date, '%B %d, %Y').date()
         elif released_date_list == 3 and released_date_list[1].isdigit(
         ) and (released_date_list[0]) == 3:
             return datetime.strptime(released_date, '%b %d, %Y').date()
         elif released_date_list == 2 and released_date_list[0].isdigit(
         ) and (released_date_list[1]) > 3:
             return datetime.strptime(released_date, '%Y %B').date()
         elif released_date_list == 2 and released_date_list[0].isdigit(
         ) and (released_date_list[1]) == 3:
             return datetime.strptime(released_date, '%Y %b').date()
         elif released_date_list == 2 and released_date_list[1].isdigit(
         ) and (released_date_list[0]) > 3:
             return datetime.strptime(released_date, '%B %Y').date()
         elif released_date_list == 2 and released_date_list[1].isdigit(
         ) and (released_date_list[0]) == 3:
             return datetime.strptime(released_date, '%b %Y').date()
         elif released_date_list == 1:
             return datetime.strptime(released_date, '%Y').date()
         else:
             return None
     except ValueError:
         LogStash.info(msg=released_date)
     except Exception as e:
         LogStash.error(msg=f'{e}|{released_date}')
 def _get_discount(self):
     """
         <div class="col search_discount responsive_secondrow">
             <span>-10%</span>
         </div>
     """
     discount_container = BSoupHandler.find_tag_by_key_value(
         soup=self.target_soup,
         tag='div',
         key='class',
         value='col search_discount responsive_secondrow')
     if discount_container is None:
         return None
     discount_span = BSoupHandler.find_tag(soup=discount_container,
                                           tag_name='span')
     rate = BSoupHandler.get_text(soup=discount_span)
     discount = self._convert_decimal(rate) if rate else None
     return 1 - discount if discount else None