Ejemplo n.º 1
0
def remove_watch_item(url):
    all_skuid = get_skuid()

    if url:
        skuid = jd.parse_url_for_skuid(url)
        if not skuid:
            return

        del all_skuid[skuid]
        save_skuid(all_skuid)
Ejemplo n.º 2
0
def remove_watch_item(url):
    all_skuid = get_skuid()

    if url:
        skuid = jd.parse_url_for_skuid(url)
        if not skuid:
            return

        del all_skuid[skuid]
        save_skuid(all_skuid)
Ejemplo n.º 3
0
def watch_item(url=None, send_msg=True, phone_num=None, phone_pwd=None):
    all_skuid = get_skuid()
    if url:
        skuid = jd.parse_url_for_skuid(url)
        if not skuid:
            return
        data = all_skuid.get(skuid, None)
        if data:
            """ update check price """
            ret = jd.run(skuid)
            if ret['price'] > 0 and ret['price'] < data['price'] and ret[
                    'stock_state'] == 1:
                """ goods on sale, notify user """
                send_title = skuid + ret['title']
                send_msg = str(ret['price'])
                notify.fetion(send_title, send_msg)

                #del ret['title']
                all_skuid[skuid] = ret
        else:
            """ new item, save into txt """
            ret = jd.run(skuid)
            if ret['price'] > 0:
                """ insert into file """
                #del ret['title']
                all_skuid[skuid] = ret

    else:
        """ traverse all_skuid to check price """
        skuids = all_skuid.keys()
        for skuid in skuids:
            ret = jd.run(skuid)
            if ret['price'] > 0 and ret['price'] < all_skuid[skuid][
                    'price'] and ret['stock_state'] == 1:
                """ goods on sale, notify user """
                send_title = skuid + ret['title']
                send_msg = str(ret['price'])
                notify.fetion(send_title, send_msg)

                #del ret['title']
                all_skuid[skuid] = ret

    save_skuid(all_skuid)
Ejemplo n.º 4
0
def watch_item(url=None, send_msg=True, phone_num=None, phone_pwd=None):
    all_skuid = get_skuid()
    if url:
        skuid = jd.parse_url_for_skuid(url)
        if not skuid:
            return
        data = all_skuid.get(skuid, None)
        if data:
            """ update check price """
            ret = jd.run(skuid)
            if ret['price'] > 0 and ret['price'] < data['price'] and ret['stock_state'] == 1:
                """ goods on sale, notify user """
                send_title = skuid + ret['title']
                send_msg = str(ret['price'])
                notify.fetion(send_title, send_msg)

                #del ret['title']
                all_skuid[skuid] = ret
        else:
            """ new item, save into txt """
            ret = jd.run(skuid)
            if ret['price'] > 0:
                """ insert into file """
                #del ret['title']
                all_skuid[skuid] = ret

    else:
        """ traverse all_skuid to check price """
        skuids = all_skuid.keys()
        for skuid in skuids:
            ret = jd.run(skuid)
            if ret['price'] > 0 and ret['price'] < all_skuid[skuid]['price'] and ret['stock_state'] == 1:
                """ goods on sale, notify user """
                send_title = skuid + ret['title']
                send_msg = str(ret['price'])
                notify.fetion(send_title, send_msg)

                #del ret['title']
                all_skuid[skuid] = ret

    save_skuid(all_skuid)