【发布时间】:2013-05-28 05:14:51
【问题描述】:
假设我的网站有源代码:
<!DOCTYPE html>
<html>
<head>
<title>Wow</title>
</head>
<body>
<div id="hello">
</div>
<script type="text/javascript">
function simple()
{
$("#hello").append("<p>Hello</p>");
}
</script>
</body>
</html>
我想要一个 C#/asp.Net 方法来提取它的源代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Wow</title>
</head>
<body>
<div id="hello">
</div>
<p>Hello</p>
</body>
</html>
string src=new WebClient().DownloadString("http://mywebsite.com")
没有帮助,因为它会提取原始 html 代码以及 javascript,与源代码相同。
【问题讨论】:
-
@mshsayem 不会。
-
您的意思是,您只想下载 HTML 源页面而不下载任何脚本代码?
-
@mshsayem 看来 OP 不想要无脚本的 html,他/她想要执行脚本。请参阅 html 中的
<p>Hello</p>。 -
@l4v 哦,我现在明白了。误解了问题。谢谢
-
@mshsayem 是的,我想要脚本执行后的 html 代码你能帮忙吗?
标签: c# asp.net c#-4.0 web-scraping