Re: parralel downloads



On Mar 9, 1:25 pm, John Deas <john.d...@xxxxxxxxx> wrote:
On Mar 8, 5:47 pm, Gary Herron <gher...@xxxxxxxxxxxxxxxxxx> wrote:



poof65 wrote:
For your problem you have to use threads.

Not at all true. Thread provide one way to solve this, but another is
the select function. For this simple case, select() may (or may not) be
easier to write. Pseudo-code would look something like this:

openSockets = list of sockets one per download file:
while openSockets:
readySockets = select(openSockets ...) # Identifies sockets with
data to be read
for each s in readSockets:
read from s and do whatever with the data
if s is at EOF: close and remove s from openSockets

That's it. Far easier than threads.

Gary Herron

You can have more information here.
http://artfulcode.nfshost.com/files/multi-threading-in-python.html

On Sat, Mar 8, 2008 at 1:11 PM, John Deas <john.d...@xxxxxxxxx> wrote:

Hi,

I would like to write a python script that will download a list of
files (mainly mp3s) from Internet. For this, I thought to use urllib,
with

urlopen("myUrl").read() and then writing the resulting string to a
file

my problem is that I would like to download several files at the time.
As I have not much experience in programming, could you point me the
easier ways to do this in python ?

Thanks,

JD
--
http://mail.python.org/mailman/listinfo/python-list

Thank you both for your help. Threads are working for me. However, a
new problem for me is that the url I want to download are in an xml
file (I want to download podcasts), and is not the same as the file
downloaded:

http://www.sciam.com/podcast/podcast.mp3?e_id=86102326-0B1F-A3D4-74B2...

will be redirected to download:

http://podcast.sciam.com/daily/sa_d_podcast_080307.mp3

is there a way, knowing the first url to get the second at runtime in
my script ?

Found it: geturl() does the job
.



Relevant Pages

  • Re: parralel downloads
    ... openSockets = list of sockets one per download file: ... I would like to write a python script that will download a list of ...
    (comp.lang.python)
  • Re: parralel downloads
    ... openSockets = list of sockets one per download file: ... new problem for me is that the url I want to download are in an xml ... knowing the first url to get the second at runtime in ...
    (comp.lang.python)
  • Re: Taskbar freezes when viewing unviewable thumbnails
    ... I 'assume' the first URL is for me to download TweakUI.exe? ... > Restore All Thumbnail Views ... >> When browsing my image files they'll start to load and then stop. ...
    (microsoft.public.windowsxp.general)
  • Re: Incorrect password or name
    ... The first URL is where you get ... the basic idea and download the ISO file that you must burn to a CD ... using a burning program that specializes in such burning, ...
    (microsoft.public.windows.vista.administration_accounts_passwords)
  • Re: Beginners Tutorial in PDF Format?
    ... W. Watson wrote: ... The first url goes to this page: ... Download Python 2.5 Documentation: ...
    (comp.lang.python)