편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.12.14

    <a href = "링크주소" > 어떻게 가져오나요? [스크래핑 프로젝트] TypeError: 'NoneType' object is not subscriptable


    Html 문에서 태크 a 의 속성인 href 의 링크주소를 가져오려고 합니다.

    제가 짠 코드로는 계속해서 다음과 같은 에러가 나옵니다.

        b = b.a['href']
    TypeError: 'NoneType' object is not subscriptable
    

    무엇이 잘못 된 걸 까요?


    코드는 밑에와 같습니다.

    browser.get("http://www.albamon.co.kr/")
    
    alba = BeautifulSoup(browser.page_source, 'html.parser')
    
    brands = alba.find(id = "MainSuperBrand").find_all("li")
    
    for b in brands :
    
    b = b.a['href']
    
    print(b)
    
  • 프로필 ramrr44님의 편집
    날짜2021.12.14

    <a href = "링크주소" > 어떻게 가져오나요? [스크래핑 프로젝트]


    Html 문에서 태크 a 의 속성인 href 의 링크주소를 가져오려고 합니다.

    제가 짠 코드로는 계속해서 다음과 같은 에러가 나옵니다. b = b.a['href'] TypeError: 'NoneType' object is not subscriptable

    무엇이 잘못 된 걸 까요?

    코드는 밑에와 같습니다.

    browser.get("http://www.albamon.co.kr/")

    alba = BeautifulSoup(browser.page_source, 'html.parser')

    brands = alba.find(id = "MainSuperBrand").find_all("li")

    for b in brands :

    b = b.a['href']

    print(b)