Wednesday, 15 August 2012

python - urllib2 not retrieving entire HTTP response -


I am confused about why I can not download the entire contents of JSN responses.

  & gt; & Gt; & Gt; Import urllib2 & gt; & Gt; & Gt; Stream = urllib2.urlopen ('http://friendfeed.com/api/room/the-life-scientists/profile?format=json') & gt; & Gt; & Gt; Stream.headers ['Content-Length'] '168928' & gt; & Gt; & Gt; Data = stream.read ()> & gt; & Gt; & Gt; Lane (data) 61058 & gt; & Gt; & Gt; #We can see here that I have not recovered the full JSON ... # that the stream has not ended with a closing ... ... gt; & Gt; & Gt; Data [-40:] CE 2-003048343 A40 "," Name ":" Vincent Rocky " 

How do I get the full response with urllib2?

The best way to get all the data:

  fp = urllib2.urlopen ("http: / Www.example.com/index.cfm ") Response =" "While 1: data = fp.read () is not data: # It may be required if data ==" ": do not miss the brake reaction + + Data Print Feedback  

The reason is that .read () is full Given the nature of the sockets, I have thought that this document was discussed (perhaps urllib ) but I can not find it.


No comments:

Post a Comment