python - Django giving [Errno 13] Permission denied -


i developing application python parses webpage , downloads images contained on webpage. using wamp webserver , django framework. python script have implemented runs expected (downloads images local desktop properly) on local computer, when try , run using on webserver django , wamp, error [errno 13] permission denied:'c:\users\user123\desktop\images'. below code, ideas what's causing error.

from django.http import httpresponse bs4 import beautifulsoup bsoup import urlparse urllib2 import urlopen urllib import urlretrieve import os import sys import zipfile django.core.servers.basehttp import filewrapper  def getdata(request): out = r'c:\users\user123\desktop\images' if request.get.get('q'):     #url = str(request.get['q'])     url = "http://google.com"     soup = bsoup(urlopen(url))     parsedurl = list(urlparse.urlparse(url))      image in soup.findall("img"):         print "old image path: %(src)s" % image     #get file name     filename = image["src"].split("/")[-1]     #get full path name if url has parsed     parsedurl[2] = image["src"]     image["src"] = '%s\%s' % (out,filename)     print 'new path: %s' % image["src"]     #       print image     outpath = os.path.join(out, filename)      #     if image["src"].lower().startswith("http"):         urlretrieve(image["src"], outpath)     else:         urlretrieve(urlparse.urlunparse(parsedurl), out) #constructs url tuple (parsedurl)      #create html file , writes check output (stored in same directory).     html = soup.prettify("utf-8")     filewrapper(open("output.html", "wb")) file:         file.write(html)      #create zip file stored (same directory htmlparser file)     zip = zipfile.zipfile('c:\users\user123\desktop\images.zip', 'w')      #path file zipped located     path = 'images'      #for each file, add zip folder.     root, dirs, files in os.walk(path):         file in files:             zip.write(os.path.join(root, file))     zip.close() else:         url = 'you submitted nothing!'  return httpresponse(url) 

your user not seem have write permissions "images" directory. set directory "world writeable" , try again.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -