def get_all_classify():
    """获取全部菜谱分类"""
    url = "https://www.xinshipu.com/%E8%8F%9C%E8%B0%B1%E5%A4%A7%E5%85%A8.html"
    response = requests.get(url, headers=get_header())
    html = BeautifulSoup(response.text, "lxml")

    all_a = html.find("div", {'class': "detail-cate-list clearfix mt20"}).find_all('a')
    classify = dict()

    for a in all_a:
        if a.has_attr('rel') and not a.has_attr('class'):
            class_url = urljoin(HOME_URL, a['href'])
            classify[a.text] = class_url

    return classify
def get_all_classify ( ) : url = "https://www.xinshipu.com/%E8%8F%9C%E8%B0%B1%E5%A4%A7%E5%85%A8.html" response = requests . get ( url , headers = get_header ( ) ) html = BeautifulSoup ( response . text , "lxml" ) all_a = html . find ( "div" , { 'class' : "detail-cate-list clearfix mt20" } ) . find_all ( 'a' ) classify = dict ( ) for a in all_a : if a . has_attr ( 'rel' ) and not a . has_attr ( 'class' ) : class_url = urljoin ( HOME_URL , a [ 'href' ] ) classify [ a . text ] = class_url return classify
获取全部菜谱分类