title: how true put try: and exception: inside beautifulsoup and file open to skip IOError
body: <pre><code>import requests
  from bs4 import BeautifulSoup
  import urllib2
  import json
  import re
  import os
  import sys
  import csv
  
  
  with open("C:/Users/Administrator/Pictures/$sample") as f:
      for row in csv.reader(f, delimiter='\n'): 
          for bokep in row:
              url = "file:///C:/Users/Administrator/Desktop/artikel/$/{}.html".format(" ".join(bokep.split()))
              jazz = open(r"C:/Users/Administrator/Videos/$/{}.html".format(" ".join(bokep.split())), 'r').read()
              soup = BeautifulSoup(jazz, "html.parser")
              with open("C:/Users/Administrator/Videos/$sample/%s.txt" % bokep, "w") as f:
  
                  for wrapper in soup.find_all('div', {
                  "class": "sample"
                  }, limit = 1):
                      out = wrapper.text.encode('utf-8').strip().replace('\n', '')
                      link = json.loads(out)["sample"]
                      title = json.loads(out)["s"]
                      f.write((bokep) + "sample")
  
                  f.write("sample")
  
                  for wrapper in soup.find_all('div', {
                  "class": "sample"
                  }, limit = 30):
                      out = wrapper.text.encode('utf-8').strip().replace('\n', '')
                      link = json.loads(out)["sample"]
                      title = json.loads(out)["s"]
                      f.write("sample")
                  f.write("sample")
                  f.close()
  </code></pre>
  
  <p>this error</p>
  
  <pre><code>Traceback (most recent call last):
    File "sample.py", line 11, in &lt;module&gt;
      with open("C:/Users/Administrator/Pictures/$sample") as f:
  IOError: [Errno 2] No such file or directory: 'C:/Users/Administrator/Pictures/$
  cabinet'
  </code></pre>
  
  <p>My question, how to be able to skip the error, for example in the file </p>
  
  <pre><code>C: /Users/Administrator/Pictures/$sample.txt
  </code></pre>
  
  <p>in the first row there</p>
  
  <pre><code>example90
  example91
  example92
  etc
  </code></pre>
  
  <p>but in the directory C:/Users/Administrator/Videos/$/ no name example90, then the script will skip to the first line will then continue to the second row without script stops and until the line in the file C:/Users/Administrator/Pictures/$sample.txt exhausted.I've tried to edit but always error and therefore you will help me an appreciation of all. thank you</p>