日期:2014-05-17 浏览次数:20435 次
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(Request.QueryString["url"].ToString()); //创建请求
httpWebRequest.Method = "GET";
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream stream; //接收数据
stream = httpWebResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(stream, System.Text.Encoding.GetEncoding("gb2312"));//设置编码
string StrOut = streamReader.ReadToEnd();
StrOut = Replace(StrOut); //地址替换
httpWebResponse.Close();
Response.Write(Server.UrlDecode(StrOut));
public static string Replace(string Htmlstring)
{
Htmlstring = Regex.Replace(Htmlstring, "href=\"http://", "href=\"LoadPage.aspx?url=http://", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "action=\"http://", "action=\"LoadPage.aspx?url=http://", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "src=\"http://", "src=\"LoadPage.aspx?url=http://", RegexOptions.Compiled | RegexOptions.IgnoreCase);
.........................
........................
}