我正在尝试在 WinRT 应用程序中发送下面的 POST 请求。
这是我使用的代码:
var pairs = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("MinOraPart", "01:00"),
new KeyValuePair<string, string>("MaxOraPart", "23:59"),
new KeyValuePair<string, string>("TIPOVIS", "FERMATE"),
new KeyValuePair<string, string>("CAMBIOCOMUNE", "0"),
new KeyValuePair<string, string>("DescLocPart", "PADOVA AUTOSTAZIONE"),
new KeyValuePair<string, string>("DescLocDest", "ROVIGO AUTOSTAZIONE"),
new KeyValuePair<string, string>("direzione", "ANDATA"),
new KeyValuePair<string, string>("gg", ""),
new KeyValuePair<string, string>("meseanno", ""),
new KeyValuePair<string, string>("ControlloEsisteFermata", "0"),
new KeyValuePair<string, string>("PARTENZA", ""),
new KeyValuePair<string, string>("LocPartenza", "348|PADOVA AUTOSTAZIONE|0"),
new KeyValuePair<string, string>("ARRIVO", ""),
new KeyValuePair<string, string>("LocArrivo", "453|ROVIGO AUTOSTAZIONE|0"),
new KeyValuePair<string, string>("dataViaggio", "14/11/2013"),
new KeyValuePair<string, string>("OREDalSol", "01:00"),
new KeyValuePair<string, string>("OREAlSol", "23:59"),
new KeyValuePair<string, string>("fascia", "libera"),
new KeyValuePair<string, string>("ordine", "NumCambi, OraPart"),
new KeyValuePair<string, string>("MaxNodi", "1"),
new KeyValuePair<string, string>("MinimoV", "0"),
new KeyValuePair<string, string>("CERCA_ANDATA", "corse di ANDATA")
}
var content = new StringContent(pairs);
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
var client = new HttpClient();
var response = await client.PostAsync("http://ro.autobus.it/ro/asp/RicercaOrari.asp?User=SITA", content);
if (response.IsSuccessStatusCode)
{
//Extract the data from the webpage
}
它可以工作,因为我从服务器获取 HTML 代码,但我收到的页面不包含查询结果,它只是没有结果的搜索页面。
似乎遗漏了请求中的某些内容,有什么建议吗?