Beispiel #1
0
def scrapy_product():
        try:
            Login().login()
            Product.correct_sku_timer()
            Product().operate()
        except Exception:
            msg = traceback.format_exception(*sys.exc_info())
            logging.error(
                ''.join(msg)
            )
            raise Exception(''.join(msg))
        finally:
            Browser().quit()
            print('do again!!!!')
Beispiel #2
0
        except Exception:
            msg = traceback.format_exception(*sys.exc_info())
            logging.error(
                ''.join(msg)
            )
            raise Exception(''.join(msg))
        finally:
            Browser().quit()
            print('do again!!!!')


if __name__ == '__main__':
    params = sys.argv
    if len(params) > 1:
        start_time = time.time()
        content = Excel(title=Product.title).read_excel(filename=params[1], date=params[2], start=int(params[3]), length=int(params[4]))
        print(content)
        print(time.time()-start_time)
        exit(1)
    else:
        try:
            #10 mim to run 
            scrapy_product()
            if Product.get_page_timer() == IS_END:
            #     # 合并文件
                Excel(Product.file_rule, Product.title_ch, Product.title).combination_files('product_'+CURRENT_DATE+'.xlsx')
                Product().send_dingding()

                #发送钉钉信息
        except Exception as e:
            Email().send("".join(str(e)))
Beispiel #3
0
def handle_get_product_price_by_id(product_id):
    if request.method == 'GET':
        return Product().get_product_price_by_id(product_id)
    else:
        return jsonify("Method Not Allowed"), 405
Beispiel #4
0
def handle_delete_product(product_id):
    if request.method == 'DELETE':
        return Product().delete_product(product_id)
    else:
        return jsonify("Method Not Allowed"), 405
Beispiel #5
0
def handle_add_new_product():
    if request.method == 'POST':
        return Product().add_new_product(request.json)
    else:
        return jsonify("Method Not Allowed"), 405