first of all sorry for my English, it's not my mother tongue. I'm writing a XML parser in python 2.7. There are a links for images, that are downloading and saving into DB, it works fine with http, but I need to download them from ftp server. Here is function that is calling from parser:
q=sa_web_images.objects.create(
web_image_url=iphoto,
web_item_id=wi_id,
non_repeat=non_repeat
)
q.get_remote_image()
Where 'iphoto' is a link, for example: http://ift.tt/1ATFx0v.
And here is function that save it into DB:
def get_remote_image(self):
if self.web_image_url and not self.web_image:
result = urllib.urlretrieve(self.web_image_url)
self.web_image.save(
os.path.basename(self.web_image_url),
File(open(result[0]))
)
self.save()
I know username and password for ftp access, but I don't know, how should I insert them into code, can someone help me please? Thanks.
No comments:
Post a Comment