title: Download CSV from web service with Python 3
body: <p>I am trying to download a CSV file from a web service with Python 3.5.3. but I always get an error.</p>
  
  <p><strong>Example</strong></p>
  
  <p>I have this url </p>
  
  <pre><code>http://www.imdb.com/list/export?list_id=watchlist&amp;author_id=ur72234145
  </code></pre>
  
  <p>If I open it with the browser it start downloading a <em>watchlist.csv</em> file.
  I wrote the followng Phython code:</p>
  
  <pre><code>import urllib
  url = 'http://www.imdb.com/list/export?list_id=watchlist&amp;author_id=ur72234145'
  response = urllib.request.Request(url)
  html = response.read()
  with open('output.csv', 'wb') as f:
       f.write(html)
  </code></pre>
  
  <p>but I get the error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "", line 1, in
    
        html = response.read() AttributeError: 'Request' object has no attribute 'read'</p>
  </blockquote>
  
  <p>what's wrong? If I use the same code with a static file path it works but it doesn't with the web service.</p>
  
  <p>I don't think this is a duplicate question because <a href="https://stackoverflow.com/questions/10622753/download-file-from-web-service-in-python-3">this</a> is about PDF and how to manage PDF, not about CSV and how to download.</p>