Web Scraping not working?
<p>So i was looking for the best thing i like about software . Then i found out about  web scraping I found it really amazing so with my python experience i got some hands-on at some Beautiful soup and requests and here's the Code</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>import html5lib
import requests
from bs4 import BeautifulSoup as BS

# Get all the a strings , next siblings and next siblings
def makeSoup(urls):
    url = requests.get(urls).text
    return BS(url,"html5lib")   

def something(soup):
    for anchor in soup.findAll("a",{"data-type":"externalLink"}):
        print(anchor.string)
        next_sibling = anchor.nextSibling
        water = str(next_sibling.string)
        water = water[0:5]
        while  water != "(202)":
            next_sibling = next_sibling.nextSibling
            if next_sibling == None:
                continue
            if next_sibling.string != None:
                print(next_sibling.string)
                water = str(next_sibling.string)
                water = water[0:5]

soup = makeSoup("http://dc.about.com/od/communities/a/EmbassyGuide.htm")
something(soup)
soup = makeSoup("http://dc.about.com/od/communities/a/EmbassyGuide_2.htm")
something(soup)
soup = makeSoup("http://dc.about.com/od/communities/a/EmbassyGuide_3.htm")
something(soup)
&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;</code></pre>
</div>
</div>
</p>

<p>But sadly all programmers nightmare ERRORS . 
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Traceback (most recent call last):
  File "C:\Users\Raj\Desktop\kunal projects\Python\listing_out_all_embassies.py", line 26, in &lt;module&gt;
    something(soup)
  File "C:\Users\Raj\Desktop\kunal projects\Python\listing_out_all_embassies.py", line 17, in something
    next_sibling = next_sibling.nextSibling
AttributeError: 'NoneType' object has no attribute 'nextSibling'</code></pre>
</div>
</div>
</p>

<p>What wrong am i doing and i am a newbie to programming as well as web-scraping . So what are some Good practices that i am not following
Anyway.thanks for reading till the end.</p>

<p>You have to check <code>next_sibling == None</code> before you can use <code>next_sibling.nextSibling</code> (and <code>break</code> when it is <code>None</code>)</p>

<pre><code>def something(soup):
    for anchor in soup.findAll("a",{"data-type":"externalLink"}):
        print(anchor.string)
        next_sibling = anchor.nextSibling
        water = str(next_sibling.string)
        water = water[0:5]
        while  water != "(202)":
            if next_sibling == None:
                break
            next_sibling = next_sibling.nextSibling
            if next_sibling == None:
                break
            if next_sibling.string != None:
                print(next_sibling.string)
                water = str(next_sibling.string)
                water = water[0:5]
</code></pre>

<p>But I could write it shorter</p>

<pre><code>def something(soup):
    for anchor in soup.findAll("a",{"data-type":"externalLink"}):
        water = None  # create variable to use it first time in "while"
        while anchor and water != "(202)":
            if anchor.string:
                print(anchor.string)
                water = anchor.string[:5]
            anchor = anchor.nextSibling
</code></pre>

python web