【问题标题】:Httpresponse Error 503Http 响应错误 503
【发布时间】:2015-07-23 10:30:12
【问题描述】:

我正在尝试从 CloudFlare 托管的网站下载网页数据。它使用 HTTPS 并在进入页面之前获取连接 ID。

我正在尝试在 WebRequest 和 WebResponse 中获取 id,但出现以下错误:

System.dll 中出现“System.Net.WebException”类型的未处理异常 附加信息:远程服务器返回错误:(503) Server Unavailable。

我试图从 Fiddler 发出请求,这是响应:

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");
}

【问题讨论】:

标签: c# http httpwebrequest cloudflare http-status-code-503


【解决方案1】:

无论您在做什么,都可能看起来像是对网站的攻击,并且会触发安全功能。您可能想要求网站所有者将发出呼叫的 IP 列入白名单。

【讨论】:

  • 我正在尝试获得与提琴手相同的响应(错误 503),我发出了 Web 请求但无法读取响应..应用程序崩溃..
【解决方案2】:

它是 Cloudflare 安全性,旨在阻止您正在尝试做的事情。您将无法使用脚本访问该网站。

【讨论】:

    【解决方案3】:

    问题是网站的正常响应是 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;
        }
    

    【讨论】:

      猜你喜欢
      • 2012-02-08
      • 1970-01-01
      • 2014-03-23
      • 2014-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-09
      • 1970-01-01
      相关资源
      最近更新 更多