次の python コードを使用して、html ページをダウンロードしました。
response = urllib2.urlopen(current_URL)
msg = response.read()
print msg
このようなページの場合、エラーなしで URL が開きますが、html ページの一部しか出力されません!
次の行で、html ページの http ヘッダーを見つけることができます。問題は「Transfer-Encoding: chunked」によるものだと思います。
urllib2 は最初のチャンクだけを返すようです! 残りのチャンクを読むのに苦労しています。残りのチャンクを読み取るにはどうすればよいですか?
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