title: Python WebScraper - object has no attribute 'urlretrieve'
body: <p>I am trying to create a python webscraper that downloads a certain amount of images from a url, to my current directory. However for the following code:</p>
  <pre><code>urllib.request.urlretrieve(each, filename)
  </code></pre>
  <p>It is saying that: AttributeError: 'function' object has no attribute 'urlretrieve' when running the program</p>
  <p>Here is the full code:</p>
  <pre><code>from urllib.request import urlopen
  from bs4 import BeautifulSoup as soup
  
  
  url = 'https://unsplash.com/s/photos/download'
  
   
  
  def download_imgs(url, amountOfImgs):
      html = urlopen(url).read()
      #parsing the html from the url
      page_soup = soup(html, &quot;html.parser&quot;)
      images = [img for img in page_soup.findAll('img')]
      counter = 0
      #compiling the unicode list of image links
      image_links = [each.get('src') for each in images]
  
      for each in image_links:
          if(counter &lt;= amountOfImgs):
              filename = each.split('/')[-1]
              urllib.request.urlretrieve(each, filename)
              counter += 1
          else:
              return image_links
  
  
  
  
  print(download_imgs(url, 5))
  </code></pre>