【发布时间】:2010-08-02 09:04:01
【问题描述】:
http://www.dsebd.org/latest_PE.php
上面的url包含了几个信息。从这个url我只想得到下面的信息。怎么做?
Price Earning Ratio : at a glance
on Aug 2, 2010 at 11:28:00
我想知道如何将 url 信息放入 C# 中的变量或某个存储容器中。具体我需要上述信息,我不需要其他信息。 我使用下面的语法:
WebClient objWebClient = new WebClient();
aRequestHTML = objWebClient.DownloadData("http://www.dsebd.org/latest_PE.php");//http://www.dsebd.org/latest_PE_all2_08.php
UTF8Encoding utf8 = new UTF8Encoding();
myString = utf8.GetString(aRequestHTML);
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(myString);
之后要做什么?我什么都猜不到。请显示一些语法
foreach (HtmlNode node in doc.DocumentNode.SelectNodes(@"//td"))//td[text()="Price Earning Ratio : at a glance"
{
if (node.InnerHtml.Contains("Price Earning Ratio"))
{
//I get the td value
}
//[text()=Price Earning Ratio : at a glance
// do stuff with node //@"//td[text()=Price Earning Ratio : at a glance"
}
添加上述语法后,我得到了下面的输出
<br>
<font color="#FFFFFF" size="3" face="Arial"><b>Price Earning Ratio : at
a glance <b> </b></b></font><br>
<font color="#FFFFFF" size="2" face="Arial"><b> on Aug 2, 2010 at 17:04:00<b></b></b></font>
<br>
从此我只想获取日期部分。如何?没有这个日期我不需要任何东西。这个日期每天都会改变,它是动态日期,所以我不能内联这个日期。从上面说我是如何得到日期的。
【问题讨论】:
-
你用的是php还是asp.net?
标签: asp.net html html-parsing html-helper