Esempio n. 1
0
 def get(self):
     s = Services()
     result = s.get_pages(7)
     return {
         'ans': 'HelloWorld',
         'daa': result
     }
Esempio n. 2
0
def run_parasing_pages(shop_id=None,
                       url_str=None,
                       entry_point_id=None,
                       limit=None,
                       interval=None):
    """
    Run parasing product page for shop_id, Run as task celery
    """
    import time
    from price.tasks import product_page_parase
    ipp = ImpPriceServices()
    if limit is not None:
        limit = int(limit) - 1
    oi = 0
    for oi, result in enumerate(ipp.get_pages(shop_id, url_str,
                                              entry_point_id)):
        if limit is not None and oi > limit:
            log.info('I stop working because a limit has been set: {}'.format(
                limit + 1))
            break
        log.info('I order url processing: {}'.format(result.url))
        product_page_parase.delay(result)
        if interval:
            log.info('Wait ... {} s.'.format(interval))
            time.sleep(int(interval))
    log.info('I oreder {} tasks'.format(oi))