服務(wù)熱線(xiàn)
153 8323 9821
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//獲取URL地址
string url = Request.Url.ToString();
txtUrl.Text = url;
//獲取IP地址
string ips= Request.UserHostAddress.ToString();
txtIp.Text = ips;
//瀏覽器
string fr = Request.Browser.Type.ToString();
// txtbrows.Text = fr;
string cp ;//= Request.UserAgent.ToString()
cp=GetOSNameByUserAgent(Request.UserAgent.ToString());
txtcp.Text = cp;
//瀏覽器
this.txtbrows.Text = Request.Browser.ClrVersion.ToString();
// txtUrl.Text = Request.ServerVariables["http_referer"];
}
protected void btnGet_Click(object sender, EventArgs e)
{
txtUrl.Text = Request.ServerVariables["http_referer"];//ServerViables["http_referer"];
string strurl= txtUrl.Text.ToString(); //欲獲取的網(wǎng)頁(yè)地址 要 http://
WebClient myWebClient = new WebClient(); //創(chuàng)建WebClient實(shí)例myWebClient
//獲取或設(shè)置用于對(duì)向 Internet 資源的請(qǐng)求進(jìn)行身份驗(yàn)證的網(wǎng)絡(luò)憑據(jù)。
myWebClient.Credentials = CredentialCache.DefaultCredentials;
// Request.ServerVariables("HTTP_HOST");
//從資源下載數(shù)據(jù)并返回字節(jié)數(shù)組。(加@是因?yàn)榫W(wǎng)址中間有"/"符號(hào))
byte[] pagedata = myWebClient.DownloadData(@strurl);
string result = Encoding.Default.GetString(pagedata); //如果獲取網(wǎng)站頁(yè)面采用的是GB2312,則使用這句
//string result = Encoding.UTF8.GetString(pagedata); //如果獲取網(wǎng)站頁(yè)面采用的是UTF-8,則使用這句
Response.Write(result); //在WEB頁(yè)中顯示獲取的內(nèi)容
Panel1.Visible = false;