ASP实现头像图像随机变换
程序员文章站
2023-12-03 11:08:58
复制代码 代码如下:<%on error resume next%> <% dim p, ppic,&n...
复制代码 代码如下:
<%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
%>