title: How to use python download all the image including gif file
body: <p>I use this code to download jpg file without any problem. But as you can see the following page source include a lot of image with path blank.gif. </p>
  
  <pre><code>&lt;a href="/en/chowchow-puppy-sleeping-dogs-pet-448311/"&gt;&lt;img src="/static/img/blank.gif"
  </code></pre>
  
  <p>My question: Is it possible to add a detect function when it is blank.gif then auto download image file with 640*426 from  "<a href="https://pixabay.com/en/chowchow-puppy-sleeping-dogs-pet-448311/" rel="nofollow noreferrer">https://pixabay.com/en/chowchow-puppy-sleeping-dogs-pet-448311/</a>" and how to archive ??</p>
  
  <pre><code>import random
  import requests
  from bs4 import BeautifulSoup
  
  # got from http://stackoverflow.com/a/16696317
  def download_file(url):
      local_filename = url.split('/')[-1]
      print("Downloading {} ---&gt; {}".format(url, local_filename))
      # NOTE the stream=True parameter
      r = requests.get(url, stream=True)
      with open(local_filename, 'wb') as f:
          for chunk in r.iter_content(chunk_size=1024): 
              if chunk: # filter out keep-alive new chunks
                  f.write(chunk)
      return local_filename
  
  def Download_Image_from_Web(url):
      source_code = requests.get(url)
      plain_text = source_code.text
      soup = BeautifulSoup(plain_text, "html.parser")
      for link in soup.findAll('img'):
          image_links = link.get('src')
          if not image_links.startswith('http'):
              image_links = url + '/' + image_links
          download_file(image_links)
  
  Download_Image_from_Web("https://pixabay.com/en/photos/?q=sleeping+puppy&amp;hp=&amp;image_type=&amp;cat=&amp;min_width=&amp;min_height=")
  </code></pre>