Hosting a html page of images on localhost and accessing it through web crawler, and downloading the image
<p>I have created a web crawler in python that accesses the web page &amp; downloads images from that page.  The code of web crawler is:</p>

<pre><code># ImageDownloader.py
# Finds and downloads all images from any given URL.

import urllib2 
import re from os.path
import basename from urlparse 
import urlsplit

url = "http://www.yahoo.com"

urlContent = urllib2.urlopen(url).read()

# HTML image tag: &lt;img src="url" alt="some_text"/&gt;

imgUrls = re.findall('img.*?src="(.*?)"', urlContent)

# download all images

for imgUrl in imgUrls:

     try:
         imgData = urllib2.urlopen(imgUrl).read()
         fileName = basename(urlsplit(imgUrl)[2])
         output = open(fileName,'wb')
         output.write(imgData)
         output.close()
     except:
         pass
</code></pre>

<p>I have to show a demo in class, so I built a simple web page with some images &amp; hosted it on <code>localhost</code> but the web crawler which I have created is not accessing the html page and not downloading the images.</p>

<p>Can anyone help me out in accessing the html page on <code>localhost</code> from the crawler?</p>
