def get_recipe_detail(recipe_url):
    """从url中获取菜谱详细信息

    :param recipe_url: str
        菜谱url，如：https://www.xinshipu.com/zuofa/598775;
        https://www.xinshipu.com//zuofa/749342
    :return:dict
    """
    response = requests.get(recipe_url, headers=get_header())
    html = BeautifulSoup(response.text, 'lxml')

    # 获取菜名
    name = html.find("div", {"class": "re-up"}).h1.text

    # 主图
    img = html.find("div", {"class": "gallery"}).a['href']
    img = urljoin(HOME_URL, img)

    all_info = html.find_all("div", {"class": "dd"})

    if len(all_info) == 4:
        # 简介
        intro = re.sub('\n|\t|\r| ', '', all_info[0].text)
        material_i = 1
        method_i = 2
    else:
        intro = None
        material_i = 0
        method_i = 1

    # 食材
    material = all_info[material_i].text.strip()
    material = re.sub('\r\n|\r\n \n|\n\n\n', '\n', material)

    # 做法
    try:
        method_steps = html.find("ol", {"class": "re-step-wpic"}).find_all('li')
        method = []
        for i, m in enumerate(method_steps, 1):
            step = dict(step_num=i)
            step['text'] = m.text.strip()
            if m.img:
                step['img_url'] = urljoin(HOME_URL, m.img['src'])
            method.append(step)
    except:
        method = all_info[method_i].text.strip()
        method = re.sub('\r\n|\r\n \n|\n\n\n\n', '\n', method)

    # 相关菜品
    classify = all_info[-1].text.strip()
    if '\xa0\xa0' in classify:
        classify = classify.replace('\xa0\xa0', ' | ')
    else:
        classify = ""

    return {
        "name": name,
        "url": recipe_url,
        "img": img,
        "intro": intro,
        "material": material,
        "method": method,
        "classify": classify
    }