Example #1
0
def display_recipe():
    user_query = session.get('a_query')
    obj = get_search_result()
    data, updated_query = obj.search(user_query)

    table_header = ['Id', 'Web Page Title', 'Image', 'Short Description']
    return render_template("table.html", data = data, user_query = user_query, updated_query = updated_query, table_header = table_header)
Example #2
0
def view_result():
    query_receive = request.args.get('query')
    dis_receive = request.args.get('display')

    movie_list = get_search_result(query_receive, dis_receive)
    
    return jsonify({ 'list': movie_list })
Example #3
0
def search():
    """
    Get track search results
    """
    search_query = request.args.get('search_query')
    result = get_search_result(search_query)
    if result is None:
        return jsonify({'success': False, 'message': 'Unable to get the data'})
    else:
        return jsonify({'success': True, 'result': result})
Example #4
0
def main():
    info = get_detail_url(get_search_result('brca1'))
    item = next(info)
    print(item)
    if os.path.exists('transcripts-{}.txt'.format(item['name'])):
        return
    transcripts = parse_page(get_page(item['url']))
    with open('transcripts-{}.txt'.format(item['name']), 'w+') as f:
        for transcript in transcripts:
            f.write('\n' + str(transcript))
Example #5
0
File: run.py Project: adexcell/d2
from search import get_search_result

if __name__ == '__main__':
    get_search_result()

Example #6
0
async def handle_msg(context):
    message = context['message']
    try:
        content = re.split(r'^小青[\s\,\,]*', message)[1]
    except:
        content = message
    if message == '小青':
        reply = await call_xiaoqing()
    elif content[:5] == 'alpha':
        question = re.split(r'^alpha[\s\,\,]*', content)[1]
        print(question)
        reply = get_answer(question)
    elif content[:2] == 'ip' or content[:4] == '你的ip':
        reply = get_localip()
    elif content in [
            '流量', '流量信息', '剩余流量', '你还剩多少流量', '你还有多少流量', '你还剩多少流量?', '你还有多少流量?'
    ]:
        reply = getOnlineUserInfo()

    elif content[:2] in ['记忆', '记住', '学习']:
        question = re.split(r'^[(记忆)(记住)(学习)]*[\s\,\,]*', content)[1]
        reply = learnQA(question)
    elif content[:2] == '对话':
        question = re.split(r'^[(对话)]*[\s\,\,]*', content)[1]
        reply = getQA(question)
    elif content[:4] == '删除对话':
        question = re.split(r'^[(删除对话)]*[\s\,\,]*', content)[1]
        reply = removeQA(question)

    elif content[:2] == '赤化':
        reply = get_pred(content[3:])
    elif content in ['测速', '测网速', '再测一次', '再测一遍']:
        await bot.send(context, '要测咯~')
        reply = '测完啦,结果:\n' + testmain()
    elif content[:2] == '决定' or content[:3] == '做决定':
        reply = make_choice(re.split(r'[\s\,\,]+', content)[1:])
    elif content[:2] == '缩写':
        reply = abbr(re.split(r'[\s\,\,]+', content)[1:])
    elif content[:3] == 'ads':
        reply = get_ads(content[4:])
    elif '身份证号' in content and ('随机' in content or '生成' in content
                                or '给我' in content or '帮我' in content):
        reply = random_id()
    elif content in [
            '你能干啥', '你能做啥', '你会干啥', '你能干什么', '你能做什么', '你会干什么', '你会做什么', '你会做啥',
            '你会干啥', '你都能干啥', '你能能做啥', '你都能干什么', '你都能做什么', '你都会什么'
    ]:
        reply = what_i_can_do()
    elif content[:4] == '获取进程':
        reply = get_process(content[4:])
    elif content[-2:] == '坐标':
        reply = get_coordinate(content[:-2])
    elif content[-2:] == '天气':
        reply = get_weather(content[:-2])
    elif content[:2] == '搜索':
        reply = get_search_result(content[3:])
    elif content[:3] == '提醒我':
        q = re.split(r'[\s]+', content[4:])
        Job = schedulers.add_job(send_sche_msg,
                                 'cron',
                                 year=q[1],
                                 month=q[2],
                                 day=q[3],
                                 hour=q[4],
                                 minute=q[5],
                                 second=q[6],
                                 args=[context, q[0]])
        reply = '记下来了。'
    elif content[:4] == '监视进程':
        q = '状态' + content[4:]
        jobsid = [i.id for i in schedulers.get_jobs()]
        if content[5:] in jobsid:
            reply = '进程已经在控制中啦。'
        else:
            schedulers.add_job(monitor_process,
                               'cron',
                               minute='*/1',
                               args=[context, q, content[5:]],
                               id=content[5:])
            reply = '知道啦,进程停下就会告诉你的。'
    elif content[:2] in ['骂人', '嘴臭']:
        reply = get_zanghua(content[3:])
    elif content[:2] in [
            '翻译', '通訳', '翻訳'
    ] or content[:6] == 'define' or content[:9] == 'translate':
        question = re.split(r'^[(翻译)(通訳)(翻訳)(define)(translate)]*[\s\,\,]*',
                            content)[1]
        reply = get_translate(question)
    elif content[:4] == '下载文献':
        reply = get_papers(content[5:])
    elif content[:4] == '删除文献':
        reply = remove_paper(content[5:])
    elif content[:4] == '文献列表':
        reply = get_paper_list()
    elif content[:4] == '台词出处':
        reply = get_lines(content[5:])
    elif content[:2] == '查词':
        reply = get_dict_result(content[3:])
    elif content[:5] == 'adnmb':
        reply = get_adnmb(content[6:])
    elif content[:2] == '笔记':
        reply = get_memo(content[3:])
    elif content[:2] == '测试':
        reply = await testbot(context, content[3:])
    elif content[:2] == '执行' or content[:7] in ['Execute', 'execute']:
        command = re.split(r'^[(执行)(Execute)(execute)]*[\s\,\,]*', content)[1]
        await shellexcute(context, command)
        reply = None

    elif content[:5] in ['天文学词典', 'astro']:
        question = re.split(r'^[(天文学词典)(astro)]*[\s\,\,]*', content)[1]
        reply = await get_astro_trans(question)
    elif content[:4] == 'bili':
        question = re.split(r'^bili[\s\,\,]*', content)[1]
        reply = await get_bili_code(question)
    elif content[:4] == 'jpnb':
        code = re.split(r'^jpnb[\s\,\,]*', content)[1]
        await get_jpnb_res(context, code)
        reply = None
    elif content in ['今日六公主', '今日列表', '今日央六列表', '今天央六节目单', '今天节目单']:
        await FetchCCTV6List_today(context)
        reply = None
    elif content in ['昨日六公主', '昨日列表', '昨日央六列表', '昨天央六节目单', '昨天节目单']:
        await FetchyCCTV6List_yestarday(context)
        reply = None

    else:
        with open('QA.json', 'r', encoding='utf-8') as f:
            data = json.load(f)
        if content in data.keys():
            answer = data[content]
            np.random.shuffle(answer)
            reply = answer[0]
        else:
            reply = chat(content)
    if reply:
        await bot.send(context, reply)