def price_parser(task, rule): try: price = _tess.recognize(task["text"], _tess.IMAGE_PNG, 32) except: log_with_time("invalid image: %s" % task["link"]) return p = fix_price(price) if not p: log_with_time("no price: %s" % task["link"]) return log_with_time("%s %s %d" % (task["link"], p, task["stock"])) ret = [(task["qid"], p, task["stock"])] return format_price(ret)
def price_parser(task, rule): price = _tess.recognize(task['text'], _tess.IMAGE_PNG, 32) try: price = re.search("\d+\.\d+|\d+", price).group() except: log_with_time("bad price: %s" % task['url']) return ret = [(task['gid'], price, task['stock'])] fret = format_price(ret) dps = {} for i in fret: dps[i[1]] = int(time.time()) return {"result":fret, "dps": dps}