从网页生成 html
Get generated html from webpage
我正在尝试从网页上进行一些网络抓取。但是屏幕上有我在源代码中找不到的信息。但是,如果我手动将网页保存为本地文件,我会得到静态生成的页面。我可以在 C# 中执行此操作吗?
下面的代码只给出了网页的来源,并没有给出我感兴趣的值。
WebClient client = new WebClient();
string sPageHtml = null;
string sUrl = @"http://www.nasdaqomxnordic.com/bonds/denmark/microsite?Instrument=XCSE0%3A5RD27SSA50";
sPageHtml = client.DownloadString(sUrl);
我建议您使用像 HtmlAgilityPack Nuget 包这样的专用工具:
Package description: this is an agile HTML parser that builds a read/write DOM and supports
plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor
XSLT to use it, don't worry...). It is a .NET code library that allows
you to parse "out of the web" HTML files. The parser is very tolerant
with "real world" malformed HTML. The object model is very similar to
what proposes System.Xml, but for HTML documents (or streams).
我想你会更容易抓住你感兴趣的东西。
我正在尝试从网页上进行一些网络抓取。但是屏幕上有我在源代码中找不到的信息。但是,如果我手动将网页保存为本地文件,我会得到静态生成的页面。我可以在 C# 中执行此操作吗?
下面的代码只给出了网页的来源,并没有给出我感兴趣的值。
WebClient client = new WebClient();
string sPageHtml = null;
string sUrl = @"http://www.nasdaqomxnordic.com/bonds/denmark/microsite?Instrument=XCSE0%3A5RD27SSA50";
sPageHtml = client.DownloadString(sUrl);
我建议您使用像 HtmlAgilityPack Nuget 包这样的专用工具:
Package description: this is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).
我想你会更容易抓住你感兴趣的东西。