當前位置:首頁 » 密碼管理 » 網站總訪問量代碼

網站總訪問量代碼

發布時間: 2022-12-30 18:15:16

1. 在asp.net中網站的總訪問量怎麼做啊 謝謝哈 要具體代碼與過程哦 !

Global.asax文件統計網站的總訪問量
void Application_Start(object sender, EventArgs e)
{
// 在應用程序啟動時運行的代碼
int count = 0;
StreamReader srd;
//取得文件的實際路徑
string file_path = Server.MapPath("counter.txt");
//打開文件進行讀取
srd = File.OpenText(file_path);
while (srd.Peek() != -1)
{
string str = srd.ReadLine();
count = int.Parse(str);

}
srd.Close();
object obj = count;
//將從文件中讀取的網站訪問量存放在Application對象中
Application["counter"] = obj;

}

void Application_End(object sender, EventArgs e)
{
// 在應用程序關閉時運行的代碼
int Stat = 0;
Stat = (int)Application["counter"];
string file_path = Server.MapPath("counter.txt");
StreamWriter srw = new StreamWriter(file_path, false);
srw.WriteLine(Stat);
srw.Close();

}

void Application_Error(object sender, EventArgs e)
{
// 在出現未處理的錯誤時運行的代碼

}

void Session_Start(object sender, EventArgs e)
{
// 在新會話啟動時運行的代碼
Application.Lock();
//數據累加
int Stat = 0;
//獲取Application對象中保存的網站總訪問量
Stat = (int)Application["counter"];
Stat += 1;
object obj = Stat;
Application["counter"] = obj;
//將數據記錄寫入文件
string file_path = Server.MapPath("counter.txt");
StreamWriter srw = new StreamWriter(file_path, false);
srw.WriteLine(Stat);
srw.Close();
Application.UnLock();

}

void Session_End(object sender, EventArgs e)
{
// 在會話結束時運行的代碼。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式設置為
// InProc 時,才會引發 Session_End 事件。如果會話模式設置為 StateServer
// 或 sqlServer,則不會引發該事件。

}

2. JS 精確統計網站訪問量的實例代碼

這篇文章介紹了JS精確統計網站訪問量的實例代碼 有需要的朋友可以參考一下 復制代碼 代碼如下: lishixin/Article/program/java/JSP/201311/20528

3. asp記錄網站總訪問量完整代碼

<%
dim count,path
count= 1
path = server.Mappath("count.txt")
Set fs=CreateObject("scripting.filesystemobject")
if(fs.FileExists(path))then
Set hs=fs.opentextfile(path)
count=hs.ReadLine
if session("iscount")="" then
session("iscount")="iscount"
count=count+1
end if
hs.close
Set hs=fs.opentextfile(path,2,true)
hs.writeline(count)
else
Set hs=fs.createtextfile(path)
hs.writeline(1)
end if
response.write "您是第"&count&"位訪問者!"
hs.close
set fs=nothing
%>
這樣就可以, 每次新打開瀏覽器才會記錄,而不是每次刷新就記錄,如果你要每次刷新都記錄也可以,追問下,我改改

4. 怎樣在asp.net網站上寫訪問量的代碼統計

看到你寫的代碼,我想告訴你,訪問量應該存在application中, 而不是在session,因為訪問量是對整站而言的。 當然你也可以使用cookie實現, 不過不推薦使用。 public int count; protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { try { this.count = Convert.ToInt32(Application["count"]); Application["count"]=this.count +1;//將訪問次數加1 } catch (Exception ee) { } } } 以上代碼簡單的展示了實現思路, 希望可以幫你解決!

5. 求一個網站訪問量代碼:代碼中包含總訪問量,今日訪問量,昨日訪問量

需要在你的網站布上統計代碼,這是前提,然後可以選擇設置統計代碼的展示樣式。用網路統計等統計工具都可以實現的。

6. 網站訪問量統計java代碼

public class Counter {

private int count;

// 每訪問一次,計數器自加一
public int getCount() {
return ++count;
}

public void setCount(int count) {
this.count = count;
}

}
<%-- 定義一個 session 范圍內的計數器 記錄個人訪問信息 --%>
<jsp:useBean id="personCount" class="com.helloweenvsfei.jspweb.bean.Counter" scope="session" />

<%-- 定義一個 application 范圍內的計數器 記錄所有人的訪問信息 --%>
<jsp:useBean id="totalCount" class="com.helloweenvsfei.jspweb.bean.Counter" scope="application" />

<div align="center">
<form action="method.jsp" method="get">
<fieldset style='width: 300'>
<legend>計數器</legend>
<table align="center" width="400">
<tr>
<td width=150 align="right" style="font-weight:bold; ">您的訪問次數:</td>
<td>
<%-- 獲取個人的 訪問次數 --%>
<jsp:getProperty name="personCount" property="count" /> 次
</td>
</tr>
<tr>
<td width=150 align="right" style="font-weight:bold; ">總共的訪問次數:</td>
<td>
<%-- 獲取所有人的 訪問次數 --%>
<jsp:getProperty name="totalCount" property="count" /> 次
</td>
</tr>
</table>
</fieldset>
</form>
</div>
希望你能幫到你

7. 網站訪問量統計java代碼怎樣寫

<DIV class="h">
<%-- 記錄網站訪問次數 --%>
<%
Integer counter = (Integer)application.getAttribute("counter"); //先從application裡面獲取計數器的key的值
if(counter==null){
//如果該值為null,說明第一次訪問
application.setAttribute("counter",1);
counter=(Integer)application.getAttribute("counter");
}else {
//如果該值不為空,取出來進行累加
int i = counter.intValue();
i++;
application.setAttribute("counter",i);//累加後再放進去
}
%>
<% User user =(User)session.getAttribute("users"); %>
<%="歡迎"+user.getName() %> |您是第<%=counter.intValue()%>位訪客
</DIV>
謝謝~

8. 有統計網站訪問量的代碼嗎

假定數據存在 abc.mdb中
abc.mdb中欄位如下:
序號(自動)
日期(訪客進入時間)
電腦(IP地址)
來自(如果訪客從www.0086it.com/?f=hello 進入本站,那會顯示「hello」)
地址(通過對IP地址分析後知道的地址(如:中國網通或北京大學))

在網站首頁中插入以下代碼:
《%
if session("0086it")<>1 then
'上面一行防止刷新給統計造成不準。
dsntemp=server.mappath("abc.mdb")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&dsntemp
set rs=server.createobject("adodb.recordset")
rs.open "db",conn,1,3
rs.addnew
rs("日期")=now()
rs("電腦")=request.servervariables("remote_addr")
rs("來自")=request.querystring("f")&"◆"&request.serverVariables("Http_REFERER")
rs("地址")=session("laizi")
'session("laizi")的值的取得不作具體介紹,是由另一程序將訪者ip地址與另外一個資料庫對比中得出來「詳細漢字地名,相當於IP地址查詢軟體中的功能)
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
session("0086it")=1
end if
%》

這樣,每次訪客訪問我站,就可以記錄他的信息。
當然,我還需要有一個程序來讀後台。
程序如下:

《%
'**********************************
'
' 訪 客 統 計 系 統'
'
' 程序設計 : 姜川
' [email protected]
' COPY請保留以上信息
'
'*********************************
'
response.expires=0
Response.Buffer=True
dim id
id=request.querystring("id")

if id="" then
id=50
end if
%》
《html》
《style type="text/css"》
《link rel="stylesheet" href="../css/one.css" type="text/css"》
《!--
.jiangc { font-size: 9pt; line-height: 12pt}
a { color: #FF0000; text-decoration: none}
a:hover { text-decoration: underline}
--》
《/style》

《body bgcolor="#FFFFFF"》
《%
dsntemp=server.mappath("abc.mdb")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};uid=admin;password=hello;dbq="&dsntemp

if request.querystring("cha")《》"" then
sql ="select * from db where 來自 like '%"&request.form("cha")&"%' order by 日期 DESC"
else
sql ="select * from db order by 序號 DESC"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%》
《p align="center"》《br》
《font face="黑體"》訪 問 統 計 系 統《/font》《/p》
《table width="700" border="0" cellspacing="1" cellpadding="0" align="center" class="jiangc" bgcolor="#000000"》
《form name="form1" method="post" action="?cha=1"》 《tr》
《td height="24" bgcolor="#ECF9FF" align="center"》 [ 共 《font color=red》《%=rs.recordcount%》《/font》
條記錄 ] 列出最近 《a href="?id=100"》100《/a》 《a href="?id=300"》300《/a》 《a href="?id=500"》500《/a》
《a href="?id=1000"》1000《/a》 《a href="?id=3000"》3000《/a》 《a href="?id=5000"》5000《/a》
《a href="?ID=《%=rs.recordcount%》&ID2=all"》所有《/a》 記錄
《input type="text" name="cha" class="jiangc" size="12"》
《input type="submit" name="Submit" value="查" class="jiangc"》
《/td》
《/tr》 《/form》
《/table》
《table width="100%" border="0" cellspacing="0"》
《tr》
《td height=2》《/td》
《/tr》
《/table》
《table border="0" cellspacing="1" cellpadding="2" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF" class="jiangc" align="center" bgcolor="#999999"》
《tr bgcolor="#CCCCCC"》
《td》 序號《/td》
《td》記錄中總編號《/td》
《td》訪問者進入日期《br》
0000000000000000000《/td》
《td》 訪問者電腦IP地址《/td》
《td》 地區《/td》
《td》 來自《/td》
《/tr》
《%
while not rs.eof and i《 cint(id)
i=i+1
%》
《tr bgcolor="#FFFFFF"》
《td align="center"》《font color=cccccc》《%=i%》《/font》《/td》
《td align="center"》 《%=rs("序號")%》 《/td》
《td》
《%
if rs("日期") 》 date() then
response.write "《font color=red》"&rs("日期")&"《/font》"
else
response.write rs("日期")
end if%》
《/td》
《td》
《%if rs("電腦")="221.215.99.61" then response.write "*" else response.write rs("電腦") end if%》
《/td》
《td》
《%=rs("地址")%》
《/td》
《td》
《%if instr(rs("來自"),"◆")《》0 then
response.write "《a href='"&right(rs("來自"),len(rs("來自"))-instr(rs("來自"),"◆"))&"' target='_blank'》"&rs("來自")&"《/a》"
end if%》
《/td》
《/tr》
《%
rs.movenext
wend
%》
《/table》
《br》
《table width="700" border="0" cellspacing="1" cellpadding="10" align="center" class="jiangc" bgcolor="#CCCCCC" bordercolor="#0000CC"》
《tr》
《td bgcolor="#EFEFEF"》備 註:《%if request.querystring("id2")=all then%》只列出最近的 《font color=red》《%=id%》《/font》 條記錄《br》
《%else%》
系統列出了所有訪問記錄《br》
《%end if%》
設 計:[email protected](MSN)《br》
設計日期:2003年03月《/td》
《/tr》
《/table》
《/html》

9. 網站訪問量統計代碼

很簡單你只要進入http://www.51.la/這里注冊以後登陸.輸入自己的網站地址就會生成一段代碼直接復制粘貼到自己網站就可以了.很好用的.我用好久了.希望能對你有用!

熱點內容
壓縮率和面縮 發布:2025-08-18 09:06:35 瀏覽:498
蘋果6splus的文件夾 發布:2025-08-18 09:01:08 瀏覽:385
macbookair解壓 發布:2025-08-18 09:00:18 瀏覽:562
python匹配空格 發布:2025-08-18 08:57:04 瀏覽:551
蘋果連接好了wifi怎麼分享給安卓 發布:2025-08-18 08:50:40 瀏覽:227
android羅盤 發布:2025-08-18 08:48:28 瀏覽:741
可離線緩存小說的小說閱讀器 發布:2025-08-18 08:41:32 瀏覽:347
我的世界中國版伺服器戰牆 發布:2025-08-18 08:28:31 瀏覽:996
雲峰會存儲 發布:2025-08-18 08:27:52 瀏覽:697
linux裝資料庫 發布:2025-08-18 08:27:12 瀏覽:389