我试图从服务中获取PNR状态(火车票状态信息)
请求格式:http://www.mmtstraintimings.in/pnrstatus/ {PNR Number}
Service URL With Valid PNR : http://www.mmtstraintimings.in/pnrstatus/8102874012
回应:
“Journey Details<\/td>\u000a<\/tr>\u000a<TR class=\"heading_table\">\u000a<td width=\"11%\">Train Number<\/Td>\u000a<td width=\"16%\">Train Name<\/td>\u000a<td width=\"18%\">Boarding Date <br>(DD-MM-YYYY)<\/td>\u000a<td width=\"7%\">From<\/Td>\u000a<td width=\"7%\">To<\/Td>\u000a<td width=\"14%\">Reserved Upto<\/Td>\u000a<td width=\"21%\">Boarding Point<\/Td>\u000a<td width=\"6%\">Class<\/Td>\u000a<\/TR>\u000a<TR>\u000a<TD class=\"table_border_both\">*19309<\/TD>\u000a<TD class=\"table_border_both\">GNC INDORE EXP <\/TD>\u000a<TD class=\"table_border_both\"> 3- 6-2012<\/TD>\u000a<TD class=\"table_border_both\">BRC <\/TD>\u000a<TD class=\"table_border_both\">INDB<\/TD>\u000a<TD class=\"table_border_both\">INDB<\/TD>\u000a<TD class=\"table_border_both\">BRC <\/TD>\u000a<TD class=\"table_border_both\"> SL<\/TD>\u000a<\/TR>\u000a<\/TABLE><table class='listings' border='0' id='listings'><tbody>\u000a<TR>\u000a<td width=\"25%\" class=\"heading_table_top\">S. No.<\/td>\u000a<td width=\"45%\" class=\"heading_table_top\">Booking Status <br \/> (Coach No , Berth No., Quota)<\/td>\u000a<td width=\"30%\" class=\"heading_table_top\">* Current Status <br \/>(Coach No , Berth No.)<\/td>\u000a<\/TR>\u000a<TR>\u000a<TD class=\"table_border_both\"><B>Passenger 1<\/B><\/TD>\u000a<TD class=\"table_border_both\"><B>W\/L 112,PQWL <\/B><\/TD>\u000a<TD class=\"table_border_both\"><B>W\/L 92<\/B><\/TD>\u000a<\/TR>\u000a<TR>\u000a<TD class=\"table_border_both\"><B>Passenger 2<\/B><\/TD>\u000a<TD class=\"table_border_both\"><B>W\/L 113,PQWL <\/B><\/TD>\u000a<TD class=\"table_border_both\"><B>W\/L 93<\/B><\/TD>\u000a<\/TR>\u000a<TR>\u000a<td class=\"heading_table_top\">Charting Status<\/td>\u000a<TD colspan=\"3\" align=\"middle\" valign=\"middle\" class=\"table_border_both\"> CHART NOT PREPARED <\/TD>\u000a<\/TR>\u000a<TR>\u000a<td colspan=\"4\"><font color=\"#1219e8\" size=\"1\"><b> * Please Note that in case the Final Charts have not been prepared, the Current Status might upgrade\/downgrade at a later stage.<\/font><\/b><\/Td>\u000a<\/TR>\u000a<\/TABLE>\u000a<BR>\u000a<TABLE wi
”
这是HTML或JSON还是什么?我不能得到它。
我认为它使用Http POST来获取信息。
使用此服务链接http://www.pnrstatuscheck.in/的网站会以此格式显示信息
我想将信息提取到实体中并按我喜欢的方式使用它。 我怎么能这样做..
任何指针都会有所帮助
我甚至制作了一个小程序来获取上述文本(我仍然无法弄清楚如何解释它)
如果你没有使用代理
,请删除代理代码 Uri uri = new Uri("http://www.mmtstraintimings.in/pnrstatus/8102874012");
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Proxy = WebRequest.DefaultWebProxy;
request.Credentials = new NetworkCredential("ID", "pass", "domain");
request.Proxy.Credentials = new NetworkCredential("id", "pass", "domain");
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
using (var response = request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
{
var result = readStream.ReadToEnd();
}
}
}
答案 0 :(得分:0)
稍微清理一下你的回复。
不知道你可能想做什么,但由于回复不完整,你甚至无法解析它..
还在Fiddler中使用XML和JSON作为接受类型的GET请求对此进行了测试。没有区别。
"Journey Details</td>
</tr>
<TR class="heading_table">
<td width="11%">Train Number</Td>
<td width="16%">Train Name</td>
<td width="18%">Boarding Date <br>(DD-MM-YYYY)</td>
<td width="7%">From</Td>
<td width="7%">To</Td>
<td width="14%">Reserved Upto</Td>
<td width="21%">Boarding Point</Td>
<td width="6%">Class</Td>
</TR>
<TR>
<TD class="table_border_both">*19309</TD>
<TD class="table_border_both">GNC INDORE EXP </TD>
<TD class="table_border_both"> 3- 6-2012</TD>
<TD class="table_border_both">BRC </TD>
<TD class="table_border_both">INDB</TD>
<TD class="table_border_both">INDB</TD>
<TD class="table_border_both">BRC </TD>
<TD class="table_border_both"> SL</TD>
</TR>
<table class='listings' border='0' id='listings'>
<tbody>
<TR>
<td width="25%" class="heading_table_top">S. No.</td>
<td width="45%" class="heading_table_top">Booking Status <br /> (Coach No , Berth No., Quota)</td>
<td width="30%" class="heading_table_top">* Current Status <br />(Coach No , Berth No.)</td>
</TR>
<TR>
<TD class="table_border_both"><B>Passenger 1</B></TD>
<TD class="table_border_both"><B>W/L 112,PQWL </B></TD>
<TD class="table_border_both"><B>W/L 91</B></TD>
</TR>
<TR>
<TD class="table_border_both"><B>Passenger 2</B></TD>
<TD class="table_border_both"><B>W/L 113,PQWL </B></TD>
<TD class="table_border_both"><B>W/L 92</B></TD>
</TR>
<TR>
<td class="heading_table_top">Charting Status</td>
<TD colspan="3" align="middle" valign="middle" class="table_border_both"> CHART NOT PREPARED </TD>
</TR>
<TR>
<td colspan="4">
<font color="#1219e8" size="1">
<b> * Please Note that in case the Final Charts have not been prepared, the Current Status might upgrade/downgrade at a later stage.</font></b>
</Td>
</TR>
</TABLE>
<BR>
<TABLE wi"