AttributeError: 'NoneType' object has no attribute 'lower' in python 3.4
Question: Code:

    
    
    import requests
    from bs4 import BeautifulSoup
    import operator
    def start(url):
        word_list =[]
        source_code =requests.get(url).text
        soup = BeautifulSoup(source_code)
        for post_string in soup.find_all('a',{'class':'cb-skin-ads-link'}):
            content = post_string.string
            words = content.lower()
            for each_word in words:
                 print(each_word)
                 word_list.append(each_word)
    
    start('http://www.cricbuzz.com/live-cricket-scorecard/16445/gl-vs-rcb-qualifier-1-indian-premier-league-2016')
    

Error:

    
    
    Traceback (most recent call last):
      File "C:/Users/Shera/PycharmProjects/Begin/wordcount.py", line 15, in <module>
        start('http://www.cricbuzz.com/live-cricket-scorecard/16445/gl-vs-rcb-qualifier-1-indian-premier-league-2016')
      File "C:/Users/Shera/PycharmProjects/Begin/wordcount.py", line 10, in start
        words = content.lower()
    AttributeError: 'NoneType' object has no attribute 'lower'
    


Answer: To understand what is going on, we should take a look at the
[documentation](https://www.crummy.com/software/BeautifulSoup/bs4/doc/#string).
There is a case when `.string` would be `None`:

> If a tag contains more than one thing, then it’s not clear what .string
> should refer to, so .string is defined to be None

You should look into using
[`get_text()`](https://www.crummy.com/software/BeautifulSoup/bs4/doc/#get-
text) instead that would take into account the children of an element as well:

    
    
    content = post_string.get_text()
    

Note that this would help to avoid the error, but you would still get no
output since the element you find really does not have any text:

    
    
    <a target="_blank" href="Javascript:void(0)" class="cb-skin-ads-link cb-skin-ads-link-fixed ad-skin" rel="noreferrer"></a>
    

