[Tutor] Trying to d0 HTTP GET

Ertl, John john.ertl at fnmoc.navy.mil
Mon Apr 18 20:02:40 CEST 2005


All,

I am trying to get some binary data from a web service.  None of the tech
guys are around so I am hoping you might be able to shed some light on what
might be happening.

Here is part of the email that explained what I needed to do.

----- clip ---

If you can do an http "get" from Python, you'll be set.
 
http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041512:global_360x181:max_wav_ht:sur
face:00000000:00000000:fcst_ops:0480

It returns an http header like the following (if the grid exists), 
followed by the grid data in big-endian, IEEE format.

         "HTTP/1.1 200 OK\r\n"
         "Server: ISIS/4.0\r\n"
         "Content-type: application/x-grid\r\n"
         "Content-length: 261234\r\n\r\n"

----- end-----

The grid data is in Binary.  How would I get to this?  I would imagine that
since f (the object) exists the call to the web service worked. Now I need
to read the grid...eventually I need to put it into a Numeric array but not
sure how to get just the grid from "f".

As a simple starting point I tried.  

>>> import urllib
>>> f =
urllib.urlopen("http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041800:global_360x18
1:max_wav_ht:surface:00000000:00000000:fcst_ops:0240")
>>> f.info()
<httplib.HTTPMessage instance at 0xb9255f6c>
>>> f.readlines()

I tried read(), readLines() and some other stuff using scipy and Numeric.

The prompt has moved to the next line but nothing else has happened for 30
min or so (I have tried several times).  When I try to close IDLE it says
the program is still running.  How should I be getting this data is it
trying to read the binary and that is why it is stalled?  

Thanks,

John Ertl 



More information about the Tutor mailing list