Asp.net mvc 4 在ASP.NET MVC 4中从爬虫检索数据

Asp.net mvc 4 在ASP.NET MVC 4中从爬虫检索数据,asp.net-mvc-4,web-crawler,Asp.net Mvc 4,Web Crawler,我有一个从网页抓取数据的程序。我想从HTML代码中获取一些数据,我该怎么做 爬网数据的一些示例: <table width="272" cellpadding="5" cellspacing="0" class="floatleft" style="border-right:1px dotted #BFBFBF"> <tr> <td width="130" class="paymentlabel"><strong>Transfer Fe

我有一个从网页抓取数据的程序。我想从HTML代码中获取一些数据,我该怎么做

爬网数据的一些示例:

<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>

我想得到转让费的价值(即11美元)、首期付款的价值(即47444美元)、第一期付款的价值(即901美元)和总额的价值(即48356美元)。有可能做到吗??谢谢你的帮助

是的,你可以。您需要一个库来加载html并允许您查询所需内容。尝试以下一种或所有方法,使您能够完全做到这一点

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;