加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP实现头像图像随机更换

发布时间:2023-06-12 12:41:02 所属栏目:Asp教程 来源:
导读:ASP实现头像图像随机更换:代码如下:<%On Error Resume Next%><%dim p, ppic, id, body, myCacherandomizep=Int((3*rnd)+1)id= Request.QueryString("id")HttpUrl="http://sms.2e7.net/可爱卡通0"&p&".gif" Set myC

ASP实现头像图像随机更换:

代码如下:

<%On Error Resume Next%>

<%

dim p, ppic, id, body, myCache

randomize

p=Int((3*rnd)+1)

id= Request.QueryString("id")

HttpUrl="http://sms.2e7.net/可爱卡通0"&p&".gif"

  Set myCache = new cache

  myCache.name = "picindex"&id

  If myCache.valid Then

          body = myCache.value

  Else

          body = GetWebData(HttpUrl)

          myCache.add body,dateadd("d",1,now)

  End If

  If Err.Number = 0 Then

        Response.CharSet = "UTF-8"

        Response.ContentType = "application/octet-stream"

        Response.BinaryWrite body

        Response.Flush

  Else

        Wscript.Echo Err.Description

  End if

'取得数据

Public Function GetWebData(ByVal strid)

Dim cidpath

cidpath = Mid(strid,1,Instr(8,strid,"/"))

Dim Retrieval

Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")

With Retrieval

.Open "Get", strid, False,"",""

.setRequestHeader "Referer", cidpath

.Send

GetWebData =.ResponseBody

End With

Set Retrieval = Nothing

End Function

%>

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章