如何获得当前页面的HTML代码
当前页面有张Form,点击其中的提交按钮时,获取
页面的HTML代码。
如何用c#实现?
------解决方案--------------------这个 测试过了 好用
<input value=提出代码已经实现!!!我的也OK了,谢谢大家! type=button onclick=go()
> <br/>
<iframe id=iframe1 style= "width:90%; height:50% " src= " "> </iframe> <br/>
<textarea id=textarea1 style= "width:90%; height:50% ">
</textarea>
<script>
function loadContent(strURL)
{
var strContent = " ";
if (typeof strURL != "string " || strURL == " ")return strContent;
try
{
var oProxy = new ActiveXObject( "Microsoft.XMLHTTP ");
oProxy[ "Open "]( "GET ", strURL, false);
oProxy[ "Send "]();
strContent = oProxy[ "responseText "];
}
catch(e){status = e.description}
return strContent;
}
function go()
{
textarea1.value=loadContent( "http://bb.news.qq.com/a/20070511/000001.htm ")
}
</script>
------解决方案--------------------up
------解决方案--------------------来学习
------解决方案--------------------前几天刚坐的这个,这个方法可以,直接传入地址就可以
public string GetHtml(string url)
{
string strValue = SetValue();
WebRequest objRequest = System.Net.HttpWebRequest.Create(url + "? " + strValue);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}
------解决方案--------------------WebRequest request = WebRequest.Create(this.Page.Request.Url);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.UTF8);
this.TextBox1.Text = HttpUtility.HtmlEncode(sr.ReadToEnd());
Response.Write(this.TextBox1.Text);
resStream.Close();
sr.Close();