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

Related Questions

I've seen some horrific code written in Perl, but I can't make head nor
I have written some code in my VB.NET application to send an HTML e-mail
I haven't written any code yet, but I've encountered a similar problem before. Hopefully
I am working on some code written by a co-worker who no longer works
I have written code that automatically creates CSS sprites based on the IMG tags
How compatible is code written under Solaris with Open Solaris ? I would be
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I am working on a software development project that uses code written primarily in
What Visual Studio settings and .emacs macros improve the likelihood that code written on
I have just been re-working an old bit of compiler-like code written using bison.

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.