Sono perplesso sul motivo per cui non riesco a scaricare l'intero contenuto di alcune risposte JSON da FriendFeed utilizzando urllib2.urllib2 non recupera l'intera risposta HTTP
>>> import urllib2
>>> stream = urllib2.urlopen('http://friendfeed.com/api/room/the-life-scientists/profile?format=json')
>>> stream.headers['content-length']
'168928'
>>> data = stream.read()
>>> len(data)
61058
>>> # We can see here that I did not retrieve the full JSON
... # given that the stream doesn't end with a closing }
...
>>> data[-40:]
'ce2-003048343a40","name":"Vincent Racani'
Come posso recuperare la risposta completa con urllib2?
il sito di rotto. Prova in un browser. –
Ottengo il 165K completo della risposta quando si colpisce quell'URL con Firefox 3.0 su Ubuntu 9.04. Il documento JSON recuperato è ben formato nel mio browser. – gotgenes
Sì, il sito è rotto. Ma questo è certamente un bug sia in 'urllib' che in' urllib2', poiché altri strumenti (curl, wget) riportano una risposta incompleta. Sarebbe bello sapere cosa c'è di sbagliato nelle librerie Python. –