Beautiful Soup 4 confusion
Question: I'm working on a little python program to get into web scraping:

    
    
    from bs4 import BeautifulSoup
    import requests
    
    hero = raw_input("Enter Hero Name: ")
    
    url = "http://www.dotahut.com/heroes/" + hero.lower().replace(' ', '_')
    
    #to double check url in case of error
    print (url)
    
    r = requests.get(url)
    soup = BeautifulSoup(r.text)
    
    # find 'weak against' heroes
    print('\nWeak Against:\n')
    for champ in soup.find(class_='weak-block').find_all(class_='champ-block'):
        print(champ.find(class_='name').get_text())
    
    # find 'strong against' heroes
    print('\nStrong Against:\n')
    for champ in soup.find(class_='strong').find_all(class_='champ-block'):
        print(champ.find(class_='name').get_text())
    

When I run this progra I get the following error:

    
    
    Traceback (most recent call last):
      File "C:\Users\LewisJames\Google Drive\Personal Files\Programming\Python\Dota 2 Counter.py", line 20, in <module>
        for champ in soup.find(class_='weak-block').find_all(class_='champ-block'):
    AttributeError: 'NoneType' object has no attribute 'find_all'
    

After reading the BS4 documentation and inspecting elements of the website I'm
very confused how this isn't working.

I am a begginer BS4 and python so please bear with me, It would be great if
you guys could help me!


Answer: The problem is with the line

    
    
    for champ in soup.find(class_='weak-block').find_all(class_='champ-block'):
    

Specifically,

    
    
    soup.find(class_='weak-block')
    

returns 'None', so the next step,

    
    
    find_all(class_='champ-block'):
    

has nothing to search, thus it returns AttributeError: 'NoneType' object has
no attribute 'find_all'

