ASP判断文件地址是否有效
<P><%</P><P>Response.Write("<head><style><!--span{ font-size: 9pt }--></style></head>")</P>
<P>On Error Resume Next</P>
<P>Dim thisurl,thistext</P>
<P>thisurl=Request("thisurl") '定义文件地址(非Html格式文档)!</P>
<P>if thisurl="" then</P>
<P>Response.Write("<span>请先输入文件地址!</span>")</P>
<P>Response.End</P>
<P>End if<BR>Function objxmlhttp(xmlurl)</P>
<P>On Error Resume Next</P>
<P>Set objxml = CreateObject("Microsoft.XMLHTTP")</P>
<P>objxml.Open "get",xmlurl,false</P>
<P>objxml.setrequestheader "content-type","application/x-www-form-urlencoded"</P>
<P>objxml.send</P>
<P>objxmlhttp = objxml.responsebody</P>
<P>if Err then</P>
<P>Err.Clear</P>
<P>Response.Write("<span>建立连接失败,文件不存在或网络有问题!;错误原因:";Err.Description;"!</span>")</P>
<P>Response.End</P>
<P>End if</P>
<P>End Function<BR>Function bytes2BSTR(vIn)</P>
<P>strReturn = ""</P>
<P>For i = 1 To LenB(vIn)</P>
<P>ThisCharCode = AscB(MidB(vIn,i,1))</P>
<P>If ThisCharCode < ;H80 Then</P>
<P>strReturn = strReturn ; Chr(ThisCharCode)</P>
<P>Else</P>
<P>NextCharCode = AscB(MidB(vIn,i+1,1))</P>
<P>strReturn = strReturn ; Chr(CLng(ThisCharCode) * ;H100 + CInt(NextCharCode))</P>
<P>i = i + 1</P>
<P>End If</P>
<P>Next</P>
<P>bytes2BSTR = strReturn</P>
<P>End Function<BR>thisurl2=Split(thisurl,",")</P>
<P>For Each ii In thisurl2</P>
<P>thistext=bytes2BSTR(objxmlhttp(ii))</P>
<P>if InStr(thistext,"<html>")<>0 then</P>
<P>Response.Write("<span>"; ii ;" <b>×</b></span><br>")</P>
<P>Else</P>
<P>Response.Write("<span>"; ii ;" <b>√</b></span><br>")</P>
<P>End if</P>
<P>Next<BR>if Err then</P>
<P>Err.Clear</P>
<P>Response.Write("<span>碰到意外!;错误原因:";Err.Description;"!</span>")</P>
<P>Response.End</P>
<P>End if</P>
<P>%></P>
页:
[1]