C#无法正确获取网站页面的源码
url:http://www.我的代码:
public static string GetPage(string url)
{
HttpWebRequest request = null;
HttpWebResponse response = null;
StreamReader reader = null;
try
{
request = (HttpWebRequest)WebRequest.Create(url)
request.Timeout = 30000;
request.Method = "GET";
request.KeepAlive = false;
request.AllowAutoRedirect = false;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
reader = new StreamReader(response.GetResponseStream(), true);
string html = reader.ReadToEnd();
return html;
}
}
catch { }
finally
{
if (response != null)
{
response.Close();
response = null;
}
if (reader != null)
reader.Close();
if (request != null)
request = null;
}
return string.Empty;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = GetPage("http://www.);
}
获取到的部分源码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<script>
var l7_scheme = 'http';
var l7_port = '80';
var l7_action_url = "http://resources.
var l7_vcode_img = 'http://resources.';
var l7_domain_img = 'default';
l7_domain_img = "*.
l7_scheme = "http";
l7_domain_img = l7_scheme + '://resources.'+ l7_domain_img + '_' + l7_port + '.jpg';
document.write("<script src='"+ l7_scheme +"://resources.'></script><link href='"+ l7_scheme +"://resources.' rel='stylesheet' type='text/css'>");
在浏览中查看到的部分源码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<HTML xmlns="http://www. xmlns:esun>
<HEAD><TITLE>EK娱乐平台 - 历史号码走势 </TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META http-equiv="Pragma" content="no-cache" />
<link href="http://upstaticcache.b0. rel="stylesheet" type="text/css" />
<link href="http://upstaticcache.b0. rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="http://upstaticcache.b0.
<script language="javascript" type="text/javascript" src="http://upstaticcache.b0.
<script language="javascript" type="text/javascript" src="http://upstaticcache.b0.
<script language="javascript" type="text/javascript" src="http://upstaticcache.b0.
<link rel="stylesheet" href="http://upstaticcache.b0. type="text/css" />
<script language="javascript" type="text/javascript" src="http://upstaticcache.b0.
<script language="javascript" src="http://upstaticcache.b0.
<script language="javascript" src="http://upstaticcache.b0.
<script language="javascript" src="http://upstaticcache.b0.
<link rel="stylesheet" href="http://upstaticcache.b0. type="text/css" />
</HEAD>
<BODY style="background: url(http://upstaticcache.b0.) repeat-x center top; margin:10px;height:100%;">
<div id="right_01">
<div class="right_01_01"><SPAN class="action-span1"><A
href="./" target='_top'>高频游戏</a> - 历史号码走势 </SPAN></div>
</div>
<script language="javascript">
fw.onReady(function(){
Chart.init();
DrawLine.bind("chartsTable","has_line");
DrawLine.color('#499495');
DrawLine.add((parseInt(0)*11+5+1),2,11,0);
DrawLine.color('#E4A8A8');
DrawLine.add((parseInt(1)*11+5+1),2,11,0);
DrawLine.color('#499495');
DrawLine.add((parseInt(2)*11+5+1),2,11,0);
DrawLine.color('#E4A8A8');
为什么会这样,请各位高手指点下!