title: URLRetrieve Error Handling
body: <p>I have the following code that grabs images using urlretrieve working..... too a point.</p>
  
  <pre><code>def Opt3():
      global conn
      curs = conn.cursor()
      results = curs.execute("SELECT stock_code FROM COMPANY")
  
      for row in results:
      #for image_name in list_of_image_names:
          page = requests.get('url?prodid=' +     row[0])
          tree = html.fromstring(page.text)
  
          pic = tree.xpath('//*[@id="bigImg0"]')
  
          #print pic[0].attrib['src']
          print 'URL'+pic[0].attrib['src']
          try:
              urllib.urlretrieve('URL'+pic[0].attrib['src'],'images\\'+row[0]+'.jpg')
          except:
              pass
  </code></pre>
  
  <p>I am reading a CSV to input the image names.  It works except when it hits an error/corrupt url (where there is no image I think).  I was wondering if I could simply skip any corrupt urls and get the code to continue grabbing images? Thanks</p>