簡體   English   中英

HTTP請求未獲得響應

[英]HTTP Request Not Getting Response

我正在嘗試將HTTP請求發送到的形式:

GET /api/content/v1/parser?url=http://blog.readability.com/2011/02/step-up-be-heard-readability-ideas/&token=1b830931777ac7c2ac954e9f0d67df437175e66e

我要與之交流的網站是www.readability.com

我一直在嘗試使用以下請求:

string readabilityUrl = "http://www.readability.com";
string requestUrl = createRequestUrl(articleUrl);

// Create http request send to readability api
System.Diagnostics.Debug.WriteLine(readabilityUrl + requestUrl);

var request = (HttpWebRequest)WebRequest.Create(readabilityUrl);
var postData = requestUrl;
var postReqData = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";

using (var stream = request.GetRequestStream())
{
    stream.Write(postReqData, 0, postReqData.Length);
}

var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

System.Diagnostics.Debug.WriteLine(responseString);

但它所做的只是獲取www.readaility.com的html內容,而不是返回我實際需要的相關數據。

我想我沒有發送正確的參數,如果您能幫助我並指出解決方案,我將不勝感激。

  1. 檢查是否由於從目標(HTTP 302)重定向而獲取HTML。 檢查您得到的內容,可能包含有關缺少憑據的錯誤或資源不存在的錯誤。

  2. 請注意,您正在創建POST請求,但是您放在開頭的示例是GET請求。

  3. 您應該使用HttpUtility.UrlEncode(url)用作參數的url進行編碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM