我正在構建一個閱讀網頁的程序。我試圖讀取301永久移動 - 重定向頁面的新鏈接在哪裏?
http://en.wikipedia.org/wiki/France
但後來我得到的迴應:
HTTP/1.0 301 Moved Permanently.
我無法理解的是,新的鏈接(在場上的位置)是我給了相同的。 ..那麼重定向頁面的新鏈接在哪裏?
這裏是迴應:
HTTP/1.0 301 Moved Permanently
Date: Wed, 16 Jan 2013 22:26:03 GMT
Server: Apache
X-Content-Type-Options: nosniff
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate
Vary: Accept-Encoding,X-Forwarded-Proto,Cookie
Last-Modified: Wed, 16 Jan 2013 22:26:03 GMT
Location: http://en.wikipedia.org/wiki/France
Content-Length: 0
Content-Type: text/html; charset=utf-8
X-Cache: MISS from sq64.wikimedia.org
X-Cache-Lookup: HIT from sq64.wikimedia.org:3128
Age: 45
X-Cache: HIT from amssq32.esams.wikimedia.org
X-Cache-Lookup: HIT from amssq32.esams.wikimedia.org:3128
X-Cache: MISS from amssq35.esams.wikimedia.org
X-Cache-Lookup: MISS from amssq35.esams.wikimedia.org:80
Connection: close
感謝
據埃裏克答案,我再次測試我的程序。
我給後續命令:
GET http://www.wikipedia.org/wiki/france HTTP/1.1
的反應是:
HTTP/1.0 301 Moved Permanently
Date: Thu, 17 Jan 2013 22:36:04 GMT
Server: Apache
Location: http://en.wikipedia.org/wiki/france
Content-Length: 243
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from sq64.wikimedia.org
X-Cache-Lookup: MISS from sq64.wikimedia.org:3128
X-Cache: MISS from amssq45.esams.wikimedia.org
X-Cache-Lookup: MISS from amssq45.esams.wikimedia.org:3128
X-Cache: MISS from knsq26.knams.wikimedia.org
X-Cache-Lookup: MISS from knsq26.knams.wikimedia.org:80
Connection: close
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://en.wikipedia.org/wiki/france">here</a>.</p>
</body></html>
預計這當然。 現在我送:
GET http://en.wikipedia.org/wiki/france HTTP/1.1
而且反應是:
HTTP/1.0 301 Moved Permanently
Date: Wed, 16 Jan 2013 22:26:03 GMT
Server: Apache
X-Content-Type-Options: nosniff
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate
Vary: Accept-Encoding,X-Forwarded-Proto,Cookie
Last-Modified: Wed, 16 Jan 2013 22:26:03 GMT
Location: http://en.wikipedia.org/wiki/France
Content-Length: 0
Content-Type: text/html; charset=utf-8
X-Cache: MISS from sq64.wikimedia.org
X-Cache-Lookup: HIT from sq64.wikimedia.org:3128
Age: 45
X-Cache: HIT from amssq32.esams.wikimedia.org
X-Cache-Lookup: HIT from amssq32.esams.wikimedia.org:3128
X-Cache: MISS from amssq35.esams.wikimedia.org
X-Cache-Lookup: MISS from amssq35.esams.wikimedia.org:80
Connection: close
我試着用wget的:
wget.exe http://en.wikipedia.org/wiki/france
及其OK!該頁面已加載:
wget.exe http://en.wikipedia.org/wiki/france
--2013-01-18 00:43:06-- http://en.wikipedia.org/wiki/france
Resolving en.wikipedia.org... 91.198.174.225
Connecting to en.wikipedia.org|91.198.174.225|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://en.wikipedia.org/wiki/France [following]
--2013-01-18 00:43:06-- http://en.wikipedia.org/wiki/France
Reusing existing connection to en.wikipedia.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 854896 (835K) [text/html]
Saving to: `France'
100%[======================================>] 854,896 573K/s in 1.5s
2013-01-18 00:43:08 (573 KB/s) - `France' saved [854896/854896]
那麼,我的程序有什麼不好?
您能顯示請求嗎? –
這是您請求的實際頁面嗎?我得到了200 OK的迴應,也許網絡中的某些內容配置錯誤。 –