def infobox(se, query):
    """
    infobox(search_engine, query)
    The function to generate infobox for the query
    """
    json = se.get_search_result(query)
    if json is None:
        print 'Error in search'
        return

    info_list = None

    for element in json:
        topic_id = element['mid']
        topic = se.get_topic_result(topic_id)
        if topic is None:
            continue

        # Parse and analyze the topic
        # Get out of the loop if the topic is valid
        # Otherwise, continue to check the next topic
        title = query.title()
        info_list = Analyser.build_infobox(topic, title)
        if len(info_list) > 0:  # Nonempty result
            # print info_list
            break

    if info_list is not None and len(info_list) > 0:
        Display.draw_infobox(info_list)
    else:
        print 'There is no result for \'' + query + '\'!'