Пример #1
0
def main():
    start_time = datetime.now()
    n = 0

    while True:
        product_ = MySQL().get_product_main()

        if product_:
            response = get_soup(url=product_['link_product'])
            sku = product_['sku']
            id_product = product_['id']
            id_category = product_['id_category']

            images = get_images(response=response)

            ftp_result = None
            if images:
                ftp_result = send_to_ftp(files=images,
                                         sku=sku,
                                         id_category=id_category)

            if ftp_result:
                MySQL().write_images(images=ftp_result)
                MySQL().set_product_main_ready(id_product=id_product)
            elif ftp_result is False:
                MySQL().set_product_main_bad(id_product=id_product)
            else:
                MySQL().set_product_main_ready(id_product=id_product)

        n += 1
        print('\rCount', n, 'Time', datetime.now() - start_time, end='')
Пример #2
0
def main():
    start_time = datetime.now()
    n = 0

    while True:
        product_ = MySQL().get_product_spec()
        if product_:

            link_ = product_['link_product']
            if link_.endswith('/'):
                link = link_ + 'spec/'
            else:
                link = link_ + '/spec/'

            response = get_soup(url=link)
            sku = product_['sku']
            id_product = product_['id']

            spec = get_spec(response=response, sku=sku)
            print(spec)
            if spec:
                MySQL().write_spec(spec=spec)
            MySQL().set_product_spec_ready(id_product=id_product)

            n += 1
            print('\rCount', n, 'Time', datetime.now() - start_time, end='')
            sleep(0.5)
Пример #3
0
def main():
    response = get_soup(
        url=
        'https://goods.ru/catalog/details/chaynik-elektricheskiy-endever-skyline-kr-335-g-600000756878/'
    )

    images = get_images_two(response=response)
    print(images)
Пример #4
0
def main():
    start_time = datetime.now()
    n = 0

    while True:
        product_ = MySQL().get_product_main()
        # print('----------------->>>')
        # print(product_['sku'])
        # MySQL().set_product_main_in_process(id_product=product_['id'])

        if product_:
            response = get_soup(url=product_['link_product'])
            sku = product_['sku']
            id_product = product_['id']
            id_category = product_['id_category']

            description = get_description(response=response)
            # images = get_images(response=response)

            result = True
            ftp_result = None
            # if images:
            #     ftp_result = save_to_disk(files=images, sku=sku, id_category=id_category)
            # if images is False:
            #     result = False

            if result and description:
                # print('IF')
                if ftp_result:
                    MySQL().write_images(images=ftp_result)
                MySQL().write_description(sku=sku, description=description)
                MySQL().set_product_main_ready(id_product=id_product)
            else:
                # print('ELSE')
                MySQL().set_product_main_ready(id_product=id_product)
                # MySQL().set_product_main_bad(id_product=id_product)

        n += 1
        print('\rCount', n, 'Time', datetime.now() - start_time, end='')
        sleep(0.5)
Пример #5
0
 def __init__(self, page_link, id_category):
     data = get_soup(url=page_link)
     self.soup = data[1]
     self.text = data[0]
     self.products = None
     self.id_category = id_category
Пример #6
0
 def __init__(self, page_link, sku):
     data = get_soup(url=page_link)
     self.soup = data[1]
     self.text = data[0]
     self.products = None
     self.sku = sku