我从来没有做过网络抓取或网络报废。但现在我需要阅读并下载forex url的特定数据,并通过开发用C#开发的自动化机器人存储到数据库中以进行进一步的数据评估。 我使用下面的代码读取网站:如何使用C#从网站中提取确切的信息?
public static string GetPage(string url)
{
try
{
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)wr.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader tr = new StreamReader(s, Encoding.ASCII);
string html = tr.ReadToEnd();
tr.Close();
s.Close();
return html;
}
catch (Exception ex)
{
throw new ApplicationException("Error downloading web page " + url.ToString(), ex);
}
}
但上面的代码是给我的地方,我需要把欧元对英镑的页面全HTML代码,美元和瑞士法郎转换率读数但没有别的。 请参考下面的图像的细节:
现在,请咨询我如何阅读这些具体的数据?有没有适当的方法来做到这一点,或者我需要从HTML提取中找到它?谢谢。
感谢您的答案,但我需要在C#中实现这个不是在asp.net中这是可以做到的C#.net? – barsan
HtmlAgilityPack与asp.net无关,你可以在任何你的C#代码中使用它。 –
[Here](http://stackoverflow.com/questions/10558149/html-agility-pack-load-and-scrape-webpage)你可以找到更多关于如何解析特定页面 –