469,271 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Download parts not whole file in ones

Hey,

My problem is, is it possible to download parts of a file while. i think
is it is called threading

My code thats download the whole webpage, and stunds the app while is is
downloading:

-----------CODE-----------
import urllib
# the heavy file to download
f = urllib.urlopen("http://da.wikipedia.org/wiki/Wiki")
# This was supposed to print the file while it downloads
while 1:
print f.read(100)
-----------/CODE-----------

In my example it just download the whole file, and then print it.

Any suggestions?

Regards
Andreas
Feb 13 '07 #1
2 1375
On Feb 13, 8:09 am, NOSPAM plz <nos...@riddergarn.dkwrote:
Hey,

My problem is, is it possible to download parts of a file while. i think
is it is called threading

My code thats download the whole webpage, and stunds the app while is is
downloading:

-----------CODE-----------
import urllib
# the heavy file to download
f = urllib.urlopen("http://da.wikipedia.org/wiki/Wiki")
# This was supposed to print the file while it downloads
while 1:
print f.read(100)
-----------/CODE-----------

In my example it just download the whole file, and then print it.

Any suggestions?

Regards
Andreas
That's because urllib.urlopen() is not a low enough level function to
allow what you want, it will simply open the . Take a look inside of
urllib.py and maybe you'll find a way to subclass the urllopen()
function to do what you want.

Cheers,
Jordan

Feb 13 '07 #2
On Feb 13, 12:51 pm, "Jordan" <jordan.tayl...@gmail.comwrote:
On Feb 13, 8:09 am, NOSPAM plz <nos...@riddergarn.dkwrote:
Hey,
My problem is, is it possible to download parts of a file while. i think
is it is called threading
My code thats download the whole webpage, and stunds the app while is is
downloading:
-----------CODE-----------
import urllib
# the heavy file to download
f = urllib.urlopen("http://da.wikipedia.org/wiki/Wiki")
# This was supposed to print the file while it downloads
while 1:
print f.read(100)
-----------/CODE-----------
In my example it just download the whole file, and then print it.
Any suggestions?
Regards
Andreas

That's because urllib.urlopen() is not a low enough level function to
allow what you want, it will simply open the . Take a look inside of
urllib.py and maybe you'll find a way to subclass the urllopen()
function to do what you want.

Cheers,
Jordan
Sorry, my previous msg got mangled. I meant to say that
urllib.urlopen() will simply open the webpage, you can't interrupt it
to print out what's already been downloaded.

Feb 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Saurabh Kumar | last post: by
6 posts views Thread by jojobar | last post: by
4 posts views Thread by Saurabh Kumar | last post: by
4 posts views Thread by Nikolay Petrov | last post: by
5 posts views Thread by sc48567189 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.