Esempio n. 1
0
    def parse_content_page(self, url):
        self.driver.get(url)

        cards = self.driver.find_elements_by_class_name("catalog-list-item__container") #articles-selector js-catalog-item")
        alkogol = []
        for card in cards:
            content = Content()

            try:
                content_category_elm = self.driver.find_element_by_tag_name("h1")
                content.category = content_category_elm.text
            except NoSuchElementException:
                print("product category missing")


            try:
                content_name_elm = card.find_element_by_class_name("catalog-list-item__title")
                content.name = content_name_elm.text
            except NoSuchElementException:
                print("product name missing")


            try:
                content_link_elm = card.find_element_by_class_name("catalog-list-item__title").get_attribute("href")
                content.link = content_link_elm
            except NoSuchElementException:
                print("product link missing")


            try:
                content_price_elm = card.find_element_by_class_name("middle_price")
                content.price = content_price_elm.text
            except NoSuchElementException:
                pass

            try:
                content_sale_elm = card.find_element_by_class_name("baseoldprice")
                content.sale = content_sale_elm.text
            except NoSuchElementException:
                content.sale = "Нет скидки"

            item = str(content)
            row = item.split(",")
            alkogol.append({
                'type' : row[0],
                'title' : row[-5],
                'link': row[-4],
                'price': row[-3],
                'sale' : row[-2],
                'availability': row[-1] 
                })
        return alkogol 
Esempio n. 2
0
    def parse_content_page(self, url):
        self.driver.get(url)
        cards = self.driver.find_elements_by_class_name("catalog_product_item_cont")
        alkogol = []
        for card in cards:
            content = Content()

            try:
                content_category_elm = self.driver.find_element_by_class_name("cont_right_col").find_element_by_tag_name("h1")
                content.category = content_category_elm.text
            except NoSuchElementException:
                print("product category missing")

            try:
                content_name_elm = card.find_element_by_class_name("product_item_name").find_element_by_tag_name("a")
                content.name = content_name_elm.text
            except NoSuchElementException:
                print("product name missing")

            try:
                content_link_elm = card.find_element_by_class_name("product_item_name").find_element_by_tag_name("a").get_attribute('href')
                content.link = content_link_elm
            except NoSuchElementException:
                print("product link missing")
            
            try:
                content_price_elm = card.find_element_by_class_name("i_price").find_element_by_tag_name("div")
                content.price = content_price_elm.text
            except NoSuchElementException:
                content.availability = "not avilable"

            item = str(content)
            row = item.split(",")
            
            print(row)
            alkogol.append({
                'type' : row[0],
                'title' : row[-5],
                'link': row[-4],
                'price': row[-3],
                'sale' : " ",
                'availability': row[-1] 
                })
        return alkogol 
Esempio n. 3
0
    def parse_content_page(self, url):
        self.driver.get(url)
        time.sleep(5)

        cards = self.driver.find_elements_by_class_name("cl_info")
        print(cards)
        alkogol = []
        for card in cards:
            content = Content()

            try:
                content_category_elm = self.driver.find_element_by_tag_name(
                    "h1")
                content.category = content_category_elm.text
                print(content.category)
            except NoSuchElementException:
                print("product category missing")

            try:
                content_name_elm = card.find_element_by_class_name(
                    "goods_name").find_element_by_tag_name("a")
                content.name = content_name_elm.text
                print(content.name)
            except NoSuchElementException:
                print("product name missing")

            try:
                content_link_elm = card.find_element_by_class_name(
                    "goods_name").find_element_by_tag_name("a").get_attribute(
                        "href")
                content.link = content_link_elm
                print(content.link)
            except NoSuchElementException:
                print("product link missing")

            try:
                content_price_elm = card.find_element_by_class_name(
                    "cl_price").find_element_by_tag_name("span")
                content.price = content_price_elm.text
                print(content.price)
            except NoSuchElementException:
                pass

            try:
                content_sale_elm = card.find_element_by_class_name(
                    "cl_price_action").find_element_by_tag_name("span")
                content.sale = content_sale_elm.text
                print(content.sale)
            except NoSuchElementException:
                content.sale = "Нет скидки"

            item = str(content)
            row = item.split(",")
            print(row)
            alkogol.append({
                'type': row[0],
                'title': row[-5],
                'link': row[-4],
                'price': row[-3],
                'sale': row[-2],
                'availability': row[-1]
            })
        return alkogol