我正在研究「個人可以工作」的事情,並且除了嘗試從.asp源文件解析某些信息到我的程序之外, 。C#颳去HTML/.asp
這是解析代碼我到目前爲止
// parse out the results
try
{
int snr_start = result.IndexOf("SNR");
int snr_end = result.IndexOf("</TR>", snr_start);
snr = result.Substring(snr_start, snr_end - snr_start);
snr = snr.Substring(snr.IndexOf("<TD>") + 1);
snr = snr.Substring(0, snr.Length - 6);
iSNR = Convert.ToInt32(snr.Substring(0, snr.IndexOf(" ")));
int dnpwr_start = result.IndexOf("Downstream Power", snr_end);
int dnpwr_stop = result.IndexOf("</TR>", dnpwr_start);
dnpwr = result.Substring(dnpwr_start, dnpwr_stop - dnpwr_start);
dnpwr = dnpwr.Substring(dnpwr.IndexOf("<TD>") + 1);
dnpwr = dnpwr.Substring(0, dnpwr.IndexOf("<TABLE") - 1);
iDPWR = Convert.ToInt32(dnpwr.Substring(0, dnpwr.IndexOf(" ")));
int uppwr_start = result.IndexOf("Upstream Power", dnpwr_stop);
int uppwr_stop = result.IndexOf("</TR>", uppwr_start);
uppwr = result.Substring(uppwr_start, uppwr_stop - uppwr_start);
uppwr = uppwr.Substring(uppwr.IndexOf("<TD>") + 1);
uppwr = uppwr.Substring(0, uppwr.IndexOf("</TD>") - 1);
iUPWR = Convert.ToInt32(uppwr.Substring(0, uppwr.IndexOf(" ")));
}
catch
這是SourceFile和我試圖從它(SNR,下行功率,上行功率)刮信息
<td class="headerR">Downstream Power</td>
<td class="contentL">1.0 dBmV</td>
</tr>
<tr>
<td class="headerR">SNR</td>
<td class="contentL">39.656 dB</td>
</tr>
<tr>
<td class="headerR">Upstream Power</td>
<td class="contentL">42.0 dBmV</td>
</tr>
不太確定我哪裏去錯了,但任何幫助將大大appreaciated。 該項目的重點是,我可以解析我的調制解調器(我是MSO員工)的信號電平以進行擴展監控。如果需要,我可以從.asp頁發佈完整的源
謝謝, 馬特