的HTML我想使用HttpWebRequest以下頁面獲得HTML:無法獲得
http://inkdispatch.com/brother
目前我使用:
public static string getHTML(string url)
{
string responseData = "";
try
{
// System.Threading.Thread.Sleep(1000 * 1);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)";
request.Timeout = 60000;
request.AllowAutoRedirect = false;
request.Method = "GET";
request.Referer = "inkdispatch.com";
request.CookieContainer = yummycookies;
request.KeepAlive = true;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(responseStream);
responseData = myStreamReader.ReadToEnd();
}
foreach (Cookie cook in response.Cookies)
{
yummycookies.Add(cook);
}
response.Close();
}
catch (Exception e)
{
responseData = "An error occurred: " + e.Message;
}
return responseData;
}
但我看不到任何東西,我得到沒有錯誤的迴應只是說,移動滲透,當我把相同的鏈接在瀏覽器中的作品。該鏈接附有一個令牌,但我確實從主頁面獲得了該信息,但仍有相同的問題。
UPDATE
我只設置:
request.AllowAutoRedirect = true;
,但我得到的錯誤:
Too many automatic redirections were attempted.
at System.Net.HttpWebRequest.GetResponse()
at inkdispatchcomScraper.Program.getHTML(String url)
,我有小提琴手開放足見其連連命中鏈接:
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
72 301 HTTP inkdispatch.com /brother?zenid=00810c6a184e63149cdca848c7f02871 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
73 301 HTTP inkdispatch.com /brother?zenid=32cf6d38541a90658d39785b6cd64fbc 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
74 301 HTTP inkdispatch.com /brother?zenid=70d0d5eaa10175d74933ba00d47876f8 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
75 301 HTTP inkdispatch.com /brother?zenid=fa45c256a07a9450274269cfa4a4e64a 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
76 301 HTTP inkdispatch.com /brother?zenid=1fb7677a7e6ae0ca32a154ebcc42e043 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
77 301 HTTP inkdispatch.com /brother?zenid=39923f8100276b1c0fa5ccfb1f8d222c 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
78 301 HTTP inkdispatch.com /brother?zenid=fef228719b375ac012c4755793a0027a 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
79 301 HTTP inkdispatch.com /brother?zenid=5c2babf5e6b9b0834f605734441ba208 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
80 301 HTTP inkdispatch.com /brother?zenid=711bdefa3ca7cccebf63b9b8a3734be1 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
81 301 HTTP inkdispatch.com /brother?zenid=c55d1b6166994be1436c9473a1519abe 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
83 301 HTTP inkdispatch.com /brother?zenid=cc66424548f23c3c64b2e0054289283f 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
84 301 HTTP inkdispatch.com /brother?zenid=6f05f06093cd345d10ca729117994ac0 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
85 301 HTTP inkdispatch.com /brother?zenid=4a2ab4d3824c4850f544f28cd71bc1bb 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
86 301 HTTP inkdispatch.com /brother?zenid=6c9d0acd69fc22821014c7e3263da7b6 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
87 301 HTTP inkdispatch.com /brother?zenid=fff05b8df3a1488add36591a2687a830 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
88 301 HTTP inkdispatch.com /brother?zenid=b10facbe8bc9b9a355fe648649067f98 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
89 301 HTTP inkdispatch.com /brother?zenid=8b767c98491178e54d12b4e85ff02b2e 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
90 301 HTTP inkdispatch.com /brother?zenid=9f0b8cb119fee9a4e276bcae5f13772d 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
91 301 HTTP inkdispatch.com /brother?zenid=943076fabf058eb1316cfa86aadb1dec 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
92 301 HTTP inkdispatch.com /brother?zenid=8bd0335032a58b9c399706cd9c695901 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
93 301 HTTP inkdispatch.com /brother?zenid=a1ba5e21f0af2750d398484e063e8303 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
94 301 HTTP inkdispatch.com /brother?zenid=e704b2951b1d136c195fd02ad4abec93 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
95 301 HTTP inkdispatch.com /brother?zenid=6d606d0785f19c17ccb1868577a9d546 0 no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981 08:52:00 GMT text/html inkdispatchcomscraper.vshost:4612
ANOTHER UPDATE
當我在IE中打開它使用重定向到/兄弟,但在代碼的情況下,它向前得到另一個ZENID螞蟻到這個情況持續發生我都看到了。
我已更新了描述,請查看。 – confusedMind 2012-04-15 17:28:58
但它在我的電腦上正常工作。 (我只需要聲明'靜態CookieContainer yummycookies =新的CookieContainer();') – 2012-04-15 17:41:00
你打哪個鏈接?它適用於http://inkdispatch.com/,但沒有其他鏈接。 – confusedMind 2012-04-15 17:44:02