how to count and extract images

Alex Martelli aleaxit at yahoo.com
Mon Oct 24 02:37:16 CEST 2005


Joe <dinamo99 at lycos.com> wrote:

> I'm trying to get the location of the image uisng 
> 
> start = s.find('<a href="somefile') + len('<a
> href="somefile') 
> stop = s.find('">Save File</a></B>',
> start) fileName = s[start:stop]
> and then construct the url with the filename to download the image 
> which works fine as cause every image has the Save File link and I can
> count number of images easy the problem is when there is more than image I
> try using while loop downlaod files, wirks fine for the first one but
> always matches the same, how can count and thell the look to skip the fist
> one if it has been downloaded and go to next one, and if next one is
> downloaded go to next one, and so on.

Pass the index from where the search must start as the second argument
to the s.find method -- you're already doing that for the second call,
so it should be pretty obvious it will also work for the first one, no?


Alex



More information about the Python-list mailing list