title: Skip Connection Interruptions (Site & BeautifulSoup)
body: <p>I'm currently doing this with my script:</p>
  
  <p>Get the body (from sourcecode) and search for a string, it does it until the string is found. (If the site updates.)</p>
  
  <p>Altough, if the connection is lost, the script stops.</p>
  
  <p>My 'connection' code looks something like this (This keeps repeating in a while loop every 20 seconds):</p>
  
  <pre><code>opener = urllib2.build_opener()
  opener.addheaders = [('User-agent', 'Mozilla/5.0')]
  
  url = ('url')
  openUrl = opener.open(url).read()
  
  soup = BeautifulSoup(openUrl)
  </code></pre>
  
  <p>I've used urllib2 &amp; BeautifulSoup.</p>
  
  <p>Can anyone tell me how I could tell the script to "freeze" if the connection is lost and look to see if the internet connection is alive? Then continue based on the answer.(So, to check if the script CAN connect, not to see if the site is up. If it does checkings this way, the script will stop with a bunch of errors.)</p>
  
  <p>Thank you!</p>