Exemple #1
0
def search(query):
    results = data_search(query)
    print query
    if results:
        return render_template("index.html", notes=results, tagsinfo=get_tagsinfo())
    else:
        return render_template("not_found.html", what="search results", tagsinfo=get_tagsinfo())
Exemple #2
0
def search(query):
    results = data_search(query)
    print query
    if results:
        return render_template('content.html',prompt="\"{}\"的搜索结果:".format(query),
                               notes=results, tagsinfo=get_tagsinfo())
    else:
        return render_template('not_found.html', what="search results",
                               tagsinfo=get_tagsinfo())
Exemple #3
0
def wechat_text_response(message):
    HELP = '''\
1.输入h查看帮助信息
2.输入w:加正文写日记,后面可以添加#标签,标签之间用空格或逗号隔开,例如"w:正文#标签1,标签2"
3.输入r读取所有日记
4.输入r:读取所有标签
5.输入r:加标签读取标签内的日记,如"r:说明"
6.输入s:加信息,对信息进行搜索,返回具有此信息的日记
ps:输入的前缀标识只能是小写字母加英文的冒号,
现在只能接受文本信息,无法接受表情和图片
'''
    if message.startswith('w:'):
        if '#' in message:
            lst = message[2:].split('#')
            content = lst[0].strip()
            tags = tags_process(lst[1].strip())
            data_store(content, tags)
            return "日记记录成功"
        else:
            content = message[2:]
            tags = []
            data_store(content,tags)
            return "日记记录成功"
    elif message in ["r","R"]:
        return '\n'.join(d['content'] for d in show_all_data())
    elif message == "r:":
        return '\n'.join(get_tagsinfo().keys())
    elif message.startswith('r:'):
        tag = message[2:].strip()
        tags = get_tagsinfo().keys()
        if tag in tags:
            return '\n'.join(d['content'] for d in show_data_for_tag(tag))
        else:
            return "没有找到这个标签"
    elif message.startswith('s:'):
        query = message[2:].strip()
        results = data_search(query)
        if results:
            return '\n'.join(d['content'] for d in results)
        else:
            return "没有搜到相关内容"
    else:
        return HELP
Exemple #4
0
def search(user):
    if request.method == 'POST':
        query = request.form['Search'].strip()
        # print(query)
        subs = data_search(query)
        col = db["Reader"]
        res = list(col.find({"email": user}))
        try:
            flname = res[0]['fname'] + " " + res[0]['lname']
        except:
            flname = ""
            user = None
        if user == "None" or user is None or len(res) == 0:
            return render_template('search.html',
                                   user="******",
                                   subs=subs,
                                   query=query)
        else:
            return render_template('search.html',
                                   user=user,
                                   flname=flname,
                                   subs=subs,
                                   query=query)
Exemple #5
0
 r_address = (
     'https://www.phoenixcontact.com/online/portal/ru/?uri=pxc-oc-itemdetail:pid='
     + str(part_num) +
     '&library=ruru&pcck=P-22-03-01-02&tab=2&selectedCategory=ALL')
 s_address = (
     'https://www.phoenixcontact.com/online/portal/ru/?uri=pxc-oc-itemdetail:pid='
     + str(part_num) +
     '&library=ruru&pcck=P-22-03-01-02&tab=1&selectedCategory=ALL')
 # request data, multiprocessing pool
 p = Pool(2)
 req_map = p.map(data_collect, [r_address, s_address])
 if req_map[0] != '0' and req_map[1] != '0':
     r = req_map[0]
     s = req_map[1]
     # search and return data
     data = data_search(r, s)
     if data != '0':
         img_src = image_search(part_num)
         if img_src != '':
             image_download(img_src, part_num)
         t1 = Terminals(part_num, data[0], data[1], data[2], data[3])
         tac1 = time.time()
         print('calculation time: ' + str(int(tac1 - tic)) + ' seconds')
         # sorted list of data for saving in excel
         TextSum = [
             t1.part_num,
             t1.type_num(), t1.desc, t1.MANUFACTURE, t1.MANUFACTURE,
             t1.part_num,
             t1.cat_page(),
             t1.pack_unit(), t1.UNIT,
             t1.weight(),