def search_order(s, refresh_count):
    start_time = time.clock()
    r = s.get(LIST_URL, timeout=PROXY_MAX_TIMEOUT)
    if r.status_code != 200:
        return -1
    result_list_page = r.text
    pos = result_list_page.find('"-order-take-')
    # print result_list_page
    if pos > -1:
        start = pos + 13
        order_id = result_list_page[start: start + ORDER_LENGTH]
        p = s.post(TAKE_ORDER_URL, data={'id': order_id})
        end_time = time.clock()
        logging.info('now refreshed %d times, and order id is %s, use %fms'
            % (refresh_count, order_id, (end_time - start_time) * 1000))
        json = p.json()
        logging.info(p.text)
        if json['success'] == True:
            print 'now refreshed %d times, and order id is %s, use %fms'\
            % (refresh_count, order_id, (end_time - start_time) * 1000)
            send_mail(MAILTO_LIST, u'抢到单啦 use auto captchar from macbookair', u'速去处理 http://buyers.youdao.com/order?id=' + str(order_id) + '\nby frellica')

            add_jpy(s, order_id)
            logging.info('add merchant done');
            time.sleep(60)
        else:
            send_mail(MAILTO_LIST, u'刷到单子但没抢到', u'杯具%s,order_id: %s,time: %f\nby frellica'\
                % (str(json), order_id, (end_time - start_time) * 1000))
    else:
        pos = result_list_page.find(u'请输入四位字母验证码')
        if pos > -1:
            s.cookies.save(COOKIE_FILE, ignore_discard=True, ignore_expires=True)
            with open('./public/img/captcha.jpg', 'wb') as f:
                r = s.get(CAPTCHA_URL)
                f.write(r.content)
            filename, retry_times = solve_captcha(s, logging)
            if filename:
                send_mail(MAILTO_LIST, u'验证码已识别', \
                    u'验证码已识别,重试了%d次,http://115.159.45.227/'%retry_times + \
                    filename.replace('public/', '') + '\nfrom frellica\n')