0

我试图从服务中获取 PNR 状态(火车票状态信息)

请求有效 PNR

请求格式:http : //www.mmtstraintimings.in/pnrstatus/ {PNR 编号}

具有有效 PNR 的服务 URL: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();
                }

            }
        }
4

1 回答 1

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"
于 2012-05-30T11:32:24.120 回答