C#从URL获取由JS加载的内容 [英] c# get content loaded by js from url
问题描述
我想从此 url 中获取表格但是内容是通过JavaScript加载的.我这样下载HTML字符串
I wanna get table from this url but content loads by javascript. I download HTML string like this
WebClient wc = new WebClient();
var html = wc.DownloadString("https://www.bloomberg.com/markets/currencies");
我如何获取javascript加载的内容?
how can i get javascript loaded content??
推荐答案
WebClient和DownloadString只会将页面内容下载为字符串,为了能够在此页面上运行JavaScript代码,您将需要一个了解以下内容的对象:DOM并可以运行JavaScript,这将是一个浏览器.
WebClient and DownloadString will just download the content of the page as string, to be able to run the JavaScript code on this page, you will need an object which understand DOM and can run JavaScript, this will be a browser.
有关此主题的更多信息:
在HtmlAgilityPack中运行脚本
加载DOM并执行javascript服务器.Net
Some more information about this subject:
Running Scripts in HtmlAgilityPack
Load a DOM and Execute javascript, server side, with .Net
这篇关于C#从URL获取由JS加载的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!