def _get_category_from_menu_info(self, category_node): item_nodes = HtmlUtils.get_elements(category_node, './/div[@class="menu-item"]') items_info = [] for item_node in item_nodes: item_name = HtmlUtils.get_element_value(item_node, './/h3[@class="menu-item-name"]/text()') if item_name != '': info = {} info['name'] = item_name info['prices'] = self._get_menu_item_prices_info(item_node) items_info.append(info) return items_info
def get_rank(self, item_node): return HtmlUtils.get_element_value( item_node, './div[@class="bs-product-rank"]/h2/text()')
def get_category_name(self, html_doc): return HtmlUtils.get_element_value( html_doc, '//div[@class="flex-horiz-product-list"]//h2[@class="best-seller-cat-title"]/text()' )
def is_top_deal(self, deal_node): return HtmlUtils.get_element_value( deal_node, './/div[@class="deal-box"]/text()') != ''
def _get_dispensary_minimum_age(self, deal_node): return '21' if HtmlUtils.get_element_value( deal_node, '//ul[@class="detail-list"]/li/span[contains(@class, "icon-retail")]' ) != '' else 'unkown'
def get_product_price(self, item_node): value = HtmlUtils.get_element_value( item_node, './/div[@class="bs-product-price"]/h4[2]/text()') currency = HtmlUtils.get_element_value( item_node, './/div[@class="bs-product-price"]/h4[1]/text()') return value + currency
def get_title(self, html_document, title_xpath): return HtmlUtils.get_element_value(html_document, title_xpath)
def _get_dispensary_address(self, deal_node): return HtmlUtils.get_element_value( deal_node, './/div[@class="text-box"]//span[@class="txt"]/text()').strip()
def _get_dispensary_phone_number(self, deal_node): return HtmlUtils.get_element_value( deal_node, './/div[@class="text-box"]//span[@class="tel-link"]/text()')
def _get_dispensary_name(self, deal_node): return HtmlUtils.get_element_value( deal_node, './/div[@class="profile-link"]/text()')
def _get_image_url(self, deal_node): return 'https://www.leafbuyer.com' + HtmlUtils.get_element_value( deal_node, '//div[contains(@class, "img-block")]/a/img/@src')
def _get_dispensary_url(self, deal_node): return 'https://www.leafbuyer.com' + HtmlUtils.get_element_value( deal_node, './/div[@class="loc-name-addr"]/strong/a/@href')
def get_date(self, html_document, date_xpath): return HtmlUtils.get_element_value(html_document, date_xpath)
def get_image_url(self, html_document, image_xpath): return HtmlUtils.get_element_value(html_document, image_xpath)
def get_brand_image(self, item_node): image_url = HtmlUtils.get_element_value( item_node, './/div[@class="bs-product-brand-image"]//img/@src') return image_url if 'http' in image_url else ''
def _get_deal_name(self, deal_node): return HtmlUtils.get_element_value( deal_node, './/div[@class="text-wrap"]/h1/text()')
def get_brand_name(self, item_node): return HtmlUtils.get_element_value( item_node, './/div[@class="bs-product-name"]/div/text()')
def _strip_quantity(self, quantity): if quantity is str: return quantity.strip() return HtmlUtils.get_element_value(quantity, './text()')
def get_image_chart(self, item_node): return HtmlUtils.get_element_value( item_node, './/div[@class="bs-product-chart"]//img/@src')
def _search_script_info(self, deal_node, script_infos): node_id = HtmlUtils.get_element_value(deal_node, './@id') for i in script_infos: if i[0] in node_id: return i return []