curl -L http://tumblr.com/tagged/long-reads
これが結果です: http://pastebin.com/XtQVubBp
その対応が違う
def download(url):
f = urllib2.urlopen(url)
return f.read()
html = download('http://tumblr.com/tagged/long-reads')
print html
これは 2 番目の結果です: http://pastebin.com/MdzrhBZv
なんで?download() がcurlと同じことを返すようにします。私は何をすべきか?
CURL リクエスト ヘッダーは次のとおりです。
$ curl -v -L http://tumblr.com/tagged/long-reads
* About to connect() to tumblr.com port 80 (#0)
* Trying 50.97.149.179... connected
* Connected to tumblr.com (50.97.149.179) port 80 (#0)
> GET /tagged/long-reads HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: tumblr.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Cache-Control: no-cache
< Content-length: 0
< Location: http://www.tumblr.com/tagged/long-reads
< Connection: close
<
* Closing connection #0
* Issue another request to this URL: 'http://www.tumblr.com/tagged/long-reads'
* About to connect() to www.tumblr.com port 80 (#0)
* Trying 50.97.143.18... connected
* Connected to www.tumblr.com (50.97.143.18) port 80 (#0)
> GET /tagged/long-reads HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: www.tumblr.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 07 May 2012 22:09:01 GMT
< Server: Apache
< P3P: CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
< Set-Cookie: tmgioct=iVajmrL8Wj8YffLTthjFyqYn; expires=Thu, 05-May-2022 22:09:01 GMT; path=/; httponly
< Vary: Accept-Encoding
< X-Tumblr-Usec: D=266934
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
編集: 今すぐ私の問題を解決してくれた人に 500 の報奨金を差し上げます。