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 615173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:11:29+00:00 2026-05-13T18:11:29+00:00

I written a code for downloading and saving images from a site .It worked

  • 0

I written a code for downloading and saving images from a site .It worked nicely,but for some urls it is being showing an error.I have paste code below

import urllib2
import webbrowser

imageurl='http://www.example.com/'+image[s]
opener1 = urllib2.build_opener()
page1=opener1.open(imageurl)
my_picture=page1.read()
image1=image[s].replace("/","")
fout = open('images/tony/'+image1, "wb")
fout.write(my_picture)
fout.close()

Actually i get many values of image[s] and is working almost condition.But when the value of image[s]=images/PG013001 GROUP 2.jpg, the compiler gives an error

  File "leather.py", line 37, in get_leather
    page1=opener1.open(imageurl)
  File "D:\Program Files\Python\lib\urllib2.py", line 395, in open
    response = meth(req, response)
  File "D:\Program Files\Python\lib\urllib2.py", line 508, in http_response
    'http', request, response, code, msg, hdrs)
  File "D:\Program Files\Python\lib\urllib2.py", line 433, in error
    return self._call_chain(*args)
  File "D:\Program Files\Python\lib\urllib2.py", line 367, in _call_chain
    result = func(*args)
  File "D:\Program Files\Python\lib\urllib2.py", line 516, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

I thought the corresponding imageurl ie ‘http://www.example.com/images/PG013001 GROUP 2.jpg’ doesn,t exist but when it is checked it exist.Please suggest a fix

regards

  • 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-05-13T18:11:29+00:00Added an answer on May 13, 2026 at 6:11 pm

    Urls can’t include spaces directly; it’s simply not allowed. What you want to do is to quote, or encode the spaces in the filename, so that the url becomes legal. Here’s wikipedia on the matter.

    So, you want to quote the urls that you pass to urllib2. In your code, you could do that by changing the one line to look like this:

    page1=opener1.open(urllib2.quote(imageurl))
    

    That oughta do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 312k
  • Answers 312k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Whether the correct tool is RegEx or ANTLR or even… May 13, 2026 at 10:36 pm
  • Editorial Team
    Editorial Team added an answer See this sample: http://code.google.com/p/robocode/source/browse/robocode/trunk/robocode.samples/src/main/java/sample/SittingDuck.java I think getDataFile("log.txt") will give you… May 13, 2026 at 10:36 pm
  • Editorial Team
    Editorial Team added an answer I may well have misunderstood big time here, but is… May 13, 2026 at 10:36 pm

Related Questions

I'm trying to accomplish the following in ASP.Net: Create a WPF Canvas control Spin
I am new here so first of all my greetings to you I am
I'm interested in maintaining a Maven 2 repository for my organization. What are the
I have written something that uses the following includes: #include <math.h> #include <time.h> #include
My question is about writing a video file to the hard drive that is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.