Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:09:02+00:00 2026-06-15T03:09:02+00:00

I have written the following code to save an album from a website. import

  • 0

I have written the following code to save an album from a website.

import urllib2
import webbrowser
import os
page=1564848
fileno=1
for fileno in range(1,24):
    pages=str(page)
    filenos=str(fileno)
    picture_page = "url-to-the-website"+pages+".jpg"
    page=page+1
    os.chdir("/home/comrider/Album/")
    if not os.path.exists("3"):
        os.makedirs("3")
    os.chdir("/home/user/Album/3")
    try:
        opener1 = urllib2.build_opener()
        page1 = opener1.open(picture_page)
        my_picture = page1.read()
        filename = filenos + picture_page[-4:]
        fileno=fileno+1
        fout = open(filename, "wb")
        fout.write(my_picture)
        fout.close()
    except:
        fileno=fileno-1 #This statement is not working
        pass

Since there are missing image number i have given a try and except statement and in the except statement I have given a statement to decrement the file no. that was incremented in the try statements. But that code is not working resulting in incomplete downloading of the album. The working platform is linux. Please help. thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:09:05+00:00Added an answer on June 15, 2026 at 3:09 am

    fileno will be reset on the next loop iteration, you can change it to whatever you want but when the current for loop iteration ends it will increment from 1..24

    from the docs:

    Python’s for statement iterates over the items of any sequence (a list
    or a string), in the order that they appear in the sequence

    range returns a list sequence you are progressing along that sequence

    if you need to mess with your counter you could use a while loop

    fileno = 1    
    while fileno < 24:
      #  do stuff
      # just remember to increment at the end, you control when the loop returns
      fileno += 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written following script in python which works fine: from sys import argv
I have written following code to get an integer from keyboard. It will prompt
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
i have written the following code class Program { static void Main(string[] args) {
I have written the following code, CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(@C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt); Report works
I have written a following code to get just the file name without extension
I have written the following code choice /m Do you want to add another
I have written the following code. But it is removing only &nbsp; not <br>
i have written the following code: As you can see there is a for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.