0
我有一個從網頁抓取數據。我想從HTML代碼中獲取一些數據,我該怎麼做?從ASP.NET MVC中檢索數據4
抓取數據的一些示例:
<table width="272" cellpadding="5" cellspacing="0" class="floatleft" style="border-right:1px dotted #BFBFBF">
<tr>
<td width="130" class="paymentlabel"><strong>Transfer Fee</strong></td>
<td width="120"> $11 </td>
<td><a href="popups/whatsTDIT.php?type=1" class="whatsTDIT"><img src="http://i.i-sgcm.com/used_cars/qmark_red_18x18.png" width="18" height="18" /></a></td>
</tr>
<tr>
<td class="paymentlabel" valign="top"><strong>Down Payment</strong></td>
<td> $47,444 (<a href="info_financial.php?ID=526494">change</a>) <p style="line-height:14px;"><span class="font_gray">Maximum 50% Loan</span></p> </td>
<td><a href="popups/whatsTDIT.php?type=2" class="whatsTDIT"><img src="http://i.i-sgcm.com/used_cars/qmark_red_18x18.png" width="18" height="18" /></a></td>
</tr>
<tr>
<td class="paymentlabel"><strong>1st Instalment</strong></td>
<td> $901 </td>
<td><a href="popups/whatsTDIT.php?type=3" class="whatsTDIT"><img src="http://i.i-sgcm.com/used_cars/qmark_red_18x18.png" width="18" height="18" /></a></td>
</tr>
<tr bgcolor="#FFF4F4">
<td class="paymentlabel" valign="top"><strong>Total</strong></td>
<td valign="top"> <strong class="font_red"> $48,356<br /><span class="font_gray" style="font-weight:normal;">(excluding insurance)</span> </strong> </td>
<td><a href="popups/whatsTDIT.php?type=4" class="whatsTDIT"><img src="http://i.i-sgcm.com/used_cars/qmark_red_18x18.png" width="18" height="18" /></a></td>
</tr>
<tr>
<td class="font_gray font_10" colspan="3" style="padding:7px 0 7px 5px; line-height:12px;">Estimates based on 50% loan at 2.80% interest rate. <br />Check with seller for exact figure.</td>
</tr>
</table>
控制器履帶:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.UserAgent = "A .NET Web Crawler";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string htmlText = reader.ReadToEnd();
return htmlText;
我想接送服務費(即$ 11)的值,首付值(即$四萬七千四百四十四) ,第一批的價值(即901美元)和總價值(即48356美元)。是否有可能這樣做?感謝幫助!!