Urllib2 python (Wrapping Encoding: chunked)

I used the following python code to load an html page:

response = urllib2.urlopen(current_URL)
msg = response.read()  
print msg

For a page like this , it opens the URL without errors, but then prints only part of the html page!

In the following lines, you can find the http headers in the html page. I think the problem is with "Transfer-Encoding: chunked".

It seems urllib2 only returns the first piece! I have difficulty reading the remaining pieces. How can I read the remaining pieces?

Server: nginx/1.0.5
Date: Wed, 27 Feb 2013 14:41:28 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: route=c65b16937621878dd49065d7d58047b2; Path=/
Set-Cookie: JSESSIONID=EE18E813EE464664EA64086D5AE9A290.tpdjo13v_3; Path=/
Pragma: No-cache
Cache-Control: no-cache,no-store,max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Vary: Accept-Encoding
Content-Language: fr
+5
source share
1 answer

I found out that if the Accept-Language header is specified, but the server does not disconnect the TCP connection, otherwise it does.

curl -H "Accept-Language:uk,en-US;q=0.8,en;q=0.6,ru;q=0.4" -v 'http://www.legifrance.gouv.fr/affichJuriJudi.do?oldAction=rechJuriJudi&idTexte=JURITEXT000024053954&fastReqId=660326373&fastPos=1'
0
source

All Articles