简体   繁体   English

wpf应用中如何显示网页信息

[英]How to display the information of a web page in a wpf application

I'm a newbie in WPF applications.我是 WPF 应用程序的新手。 I want to create a application that displays the information from a web page.. For example, my application should display the stock price of a particular company using the data in a particular site.我想创建一个显示网页信息的应用程序。例如,我的应用程序应该使用特定站点中的数据显示特定公司的股票价格。

I want to use moneycontrol to fetch the stock price of infosys... How can I achieve this?我想使用moneycontrol来获取infosys的股票价格...我怎样才能做到这一点?

There are 2 ways ways depending on the way you want to show information..根据您要显示信息的方式,有 2 种方式。

Either you can use WebControl to show the Website itself in that control,您可以使用WebControl在该控件中显示网站本身,

But i think you are looking for extracting or web scraping the data from the Web Page then you can try using the HtmlAgilityPack to parse the Html and extract the required info from there但我认为您正在寻找从网页中提取或网络抓取数据然后您可以尝试使用HtmlAgilityPack来解析 Html 并从那里提取所需的信息

A sample code:示例代码:

string tickerid = "Bse_Prc_tick";
HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().Load(@"http://www.moneycontrol.com/india/stockpricequote/computers-software/infosys-technologies/IT", "GET");

if(doc != null)
{
   // Fetch the stock price from the Web page
   string stockprice = doc.DocumentNode.SelectSingleNode(string.Format(".//*[@id='{0}']",tickerid)).InnerText;
   Console.WriteLine(stockprice);
}

Output:输出:

2585.55

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM