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

  • SEARCH
  • Home
  • 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 9227051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:58:30+00:00 2026-06-18T04:58:30+00:00

what I am trying to achieve is to get binary data(of an image) from

  • 0

what I am trying to achieve is to get binary data(of an image) from a url that generates an image through a php script (on the fly) and save that data to the database using sqlalchemy. When i try to achieve this using the python or ipython interpreter the data is returned but using the same code in the script the data is a blank string.

Using the Interpreter:

>>>import urllib
>>>link = 'http://www.example.com/getImage.php?e=23f4904fhsdajf0xns3erre32q886heipxd8c447gf8gs9b9d'
>>>image = urllib.urlopen(link).read()
>>>image

Returns the following binary data:

>>>’\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00H\x00H\x00\x00\xff\xe1\x00\x18Exif\x00\x00II*\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xe1\x03)http://ns.adobe.com/xap/1.0/\x00 \xff\xdb\x00C\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x02\x02\x01\x01\x02\x01\x01\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\xff\xc0\x00\x0b\x08\x00\x16\x01,\x01\x01\x11\x00\xff\xc4\x00\x1b\x00\x01\x00\x03\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x07\x08\x05\t\n\x03\xff\xc4\x00$\x10\x00\x02\x02\x03\x01\x01\x01\x00\x02\x02\x03\x00\x00\x00\x00\x00\x05\x06\x04\x07\x02\x03\x08\x00\x01\t\n\x14\x12\x17\x13\x15\x16\xff\xda\x00\x08\x01\x01\x00\x00?\x00\xfb\xf8\xf3\xcf<\xf7$\xf9\xf0J\xa0\x8d44\x1a\x12\xb6\xb2\xb6$\x89\xf6&#\xe4a\x87\x04\x04\x10x{\x88\x974h\xb9\x1d\xda\xe3\x8b\x13\x14|y\x1b\xe4\xc9\xdf\xb3^\x9d\x1atg\xb7nx\xe1\x8eY|\xfc\xd6\xd9\x17\\x97@7\xa8\x1f\n\xd6\xa4\xd6\x14S”\xbbB\xd9X\’WY\x17N\xc1\xd0P!\xf0\x06\xc5\xef\xdb\x18\xc0Y\x83%F\x91\x16T}\xbb4H\xd1\’^\xed;3\xd7\x9e9}\xedz\x16\xc3d\xd7j\’\xc0*\xb5\xbf%\xac45\xc4\x92A]m\x85\xa4\x18S\xec\x90!6!\xa1L\x9a\x009)\xfa\xa4\x18\x89\xa9\xea\xd4\xac\x02\xed\xdb\x1f^\xcc5\x96\xb1\xc0\x8e\xcb/\x93\x0c\x0f\xd3″i\xec\xfe\xb7\xd6\\xb0\xe5g\xce\xa4\x94:\x9f\xda\xaeq\x9b\x88\xc6%Q-\xdc\xb5\xd1\xcb<|\x81\x18\xe5\x99m\x13\x90E\xb1\xed+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9a\xf5\x83e\x19.\x7f%\x9b\xff\x00m\xfd\xc5_\x96\xf6?\xaf\x18s\xa6<\xc5/\x1e^\xff\x00Y\xed\xe9\xcd\xdd\x17\x9d\xe9\x8d\xe3{\xe2koH\xe7\xccZp9\x8b\x0et\xc7\xced\xcd\x13\x0b\x8b\x1f\xfal \xec7\x85\x89\x96m\xd8\x9c\xcf\xed}W\xd1\xbd\xd5f\xd9uT\x9e\xa3t\xed\x95\xe6\x86\xfe\xc9\xa8\xaa\xbe\x86\x8dS\xdd\x9d\tZS\xe3i\xcd_\x82u\xd5\x93l\x1cE\xc2\xaeg\x1e\r:\xbb\x91\xfaJ\xa3\xb4v-\xc0~\xc3\xd7\xa9\xbeQ%\xc1\xc5\xa3O8b\x11\x0fh\xb8$\x85\xb4[\x85\xf8\xb8\xad\xfb\xad\xcbM\xecO\x93y\xd0\x85\xd5\xa6\xc5\x1aH5\x83\xaa\xda\x9bO\xa7I\xb1\xf5\xbd\x873\x17D\xc1NX\xb8\xec3\xf0\xa4izt\xc9\xd1;\xe6\xfd[\xf5k\xdb\x86X|\xd6>y\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9e\xaa\xeazV\xb8\xa4E\xb4\x89\xaeB\x91\x19\xa9\xe1\xe9\x8e\xcbq u\xb1\xc1\xe9\x8d\xa1\xe1\xab(\x98\x17m\xcb\x0f\x99g\xf3/\xbf>}\xf4yw\x8ay\xa5V\xfb\x9f\xd3\x00\xeb\xe9\xf1m\xd9\xc4\xda\x0f\xea\x9f”\xc2\xb3\x89#\x82ky\x13\x14\x0b\xd3\xcau:Q\xcfrj-\x84t,L”\x9ba\x0c\x02\x01\xb2\xfa7o\xd6F|\x9ceI\xf9\xb7Ty\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xe7\x9ey\xef\xff\xd9′

Now using the same code in a script as follows:

def get_image(link):
    print link #Debug: Check if link has been passed
    image = urllib.urlopen(link).read()
    print type(image), image
    return image

the first print statement returns:

http://www.example.com/getImage.php?e=23f4904fhsdajf0xns3erre32q886heipxd8c447gf8gs9b9d

and the second one:

type,

Why is it that the same code would produce different results? Can any one think of a possible cause here ?

  • 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-18T04:58:31+00:00Added an answer on June 18, 2026 at 4:58 am

    While I dont know why would you get a different results when running from script vs running from the interpreter, what I’d do in first place is to ditch urrlib in favor of Requests library: http://docs.python-requests.org/en/latest/user/quickstart/#response-content I’ve been fetching a lot of different content with it from scripted apps and so far never had an issue.

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

Sidebar

Related Questions

I'm trying to achieve two things, both of which I fail to get at.
Trying to achieve any moving effect while appending an element from one to another
What i'm trying to achieve is playing a guitar chord from my python application.
MongoDB's distinct command is perfect for what I'm trying to achieve, which is get
Ultimately I am trying to achieve an autocomplete list from webservice results and thus
This is what I am trying to achieve: This is what I get: Please
im trying to achieve something that i thought it was easy, but the reality
Im trying to achieve a design that has five columns with fluid width, but
I'm trying to achieve an application that allows to shoot a photo and display
I am trying to get a list of DLLs that a given process is

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.