Kodi Community Forum

Full Version: Download snipet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
firstly i want some code which can download a file from a webpage.

at them moment i use something like
Quote:tmpweb = urllib.urlopener()
tmpweb.retrieve(str(http://www.google.com.au/intl/en_au/images/logo.gif", q:\\temp\\img.gif), "q:\\temp\temp.gif"))

first i want/need a way of showing a progress bar while a file download

second i want to be able to set the referering url?
for extra info the referer is the site which link or sent you to another.

i have noticed something with the urllib2. here is a example from the python site. i haven't yet tested this to see if it can get avi's or gif's yet.
Quote:import urllib, urllib2
req = urllib2.request("http://google.com.au/")
req.add_header("referer", "http://google.com")
webdata = urllib2.urlopen(req)
the only thing is getting the result from the open and writing them file. in the urlopener the retive comand does this for you.

then using webdata.read() i need to be able to write a file. any ideas?. if there is a function like retrive( req, filename) that would be good too.


and help would be greatly appericateted.