2015-05-12 152 views
2

我在嘗試從CloudFlare託管的網站下載網頁數據。它在進入頁面之前使用HTTPS並獲取連接的ID。Httpresponse錯誤503

我試圖獲得的WebRequest和WebResponse的ID,但我發現了以下錯誤:

An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The remote server returned an error: (503) Server Unavailable.

我試圖讓從提琴手的請求,這裏是迴應:

HTTP/1.1 503 Service Temporarily Unavailable 
Date: Tue, 12 May 2015 13:38:17 GMT 
Content-Type: text/html; charset=UTF-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
Set-Cookie: __cfduid=d57a7d982035dad7ebafe63444d125e451431437897; expires=Wed, 11-May-16 13:38:17 GMT; path=/; domain=.hornystress.me; HttpOnly 
X-Frame-Options: SAMEORIGIN 
Refresh: 8;URL=/cdn-cgi/l/chk_jschl?pass=1431437901.815-Ym1g5qTodK 
Cache-Control: no-cache 
Server: cloudflare-nginx 
CF-RAY: 1e5685ed559606ee-LHR 

這裏是我的代碼:

public static string GetCookie(string link) 
{ 
    WebRequest request = WebRequest.Create("https://hornystress.me"); 
    request.Proxy = WebProxy.GetDefaultProxy(); 
    request.Timeout *= 100; 
    WebResponse response = request.GetResponse(); 
    return response.Headers.Get("Set-Cookie"); 
} 
+0

我編輯了自己的冠軍。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

+0

任何一個?請重要 –

回答

0

的問題是網站的正常反應是Error code 503用,我想一個cookie ...所以編譯器會引發一個WebException錯誤;至極我應該抓住......

public static string GetCookie() 
    { 
     WebRequest request = WebRequest.Create("https://hornystress.me"); 
     request.Proxy = WebProxy.GetDefaultProxy(); 
     request.Timeout *= 100; 
     string cookie; 
     WebResponse response; 
     try 
     { 
      response = request.GetResponse(); 
      cookie = response.Headers.Get("Set-Cookie"); 
     } 
     catch (WebException we) 
     { 
      cookie=we.Response.Headers.Get("Set-Cookie"); 
     } 
     return cookie; 
    } 
1

不管你在做可能看起來像針對攻擊網站&它觸發了一項安全功能。您可能希望要求網站所有者將正在撥打的IP列入白名單。

+0

我試圖得到相同的響應,在提琴手(與錯誤503),我提出了網絡請求,但不能讀取響應..該應用程序崩潰.. –

0

這是Cloudflare安全性,旨在阻止您嘗試做的確切事情。您將無法使用腳本訪問該網站。