链接转向的问题 思路:用xmlhttp来判断R开头的文件是否存在。然后根据返回成功与否,再转向 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to net_lover:大侠,把脚本写出来好么to weidegong:最好是自动搜索。 试一下这个ASP文件,你也许需要用第二个oRegExp.Pattern,而且需要改动其中的模式<%@ Language="VBSCRIPT"%><%Option Explicit%><%DIM xmlhttp, matches,sURL,sHomeURL,sContent, oRegExp, oMatch, nIndex, nCount, sPathsURL = "http://msdn.microsoft.com"sHomeURL = "http://www.microsoft.com"set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")xmlhttp.Open "GET",sURL, FALSExmlhttp.SendsContent = xmlhttp.ResponseTextset oRegExp = new RegExpoRegExp.Pattern = "<a\s+href=[""']?([^""'\s]+)[""']?\s*[^>]*>"'oRegExp.Pattern = "<a\s+href=[""']?(r[^""'\s]+)[""']?\s*[^>]*>"oRegExp.IgnoreCase = TRUEoRegExp.Global = TRUEset matches = oRegExp.Execute(sContent)if matches.Count = 0 then Response.Redirect sHomeURLelse Randomize nIndex = Int(matches.Count * RND()) set oMatch = matches(nIndex) sPath = oMatch.SubMatches(0) if Instr(sPath,"http://") = 0 then if Left(sPath,1) = "/" then sPath = sHomeURL & sPath else sPath = sHomeURL & "/" & sPath end if end if Response.Redirect sPathend if'nCount = 0'for each oMatch in matches ' nCount = nCount + 1 'Response.Write "*****" & nCount & "*****<BR>" 'Response.Write oMatch.Value & "<BR>" 'Response.Write "href:" & oMatch.SubMatches(0) & "<BR>" 'Response.Write "**********<BR><BR>"'next%> 这里最主要的是要取得那个HTML文件,我这里用的是MSXML解释器里的组件,set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")xmlhttp.Open "GET",sURL, FALSExmlhttp.SendsContent = xmlhttp.ResponseText然后是用正则表达式得出所有的连接,set oRegExp = new RegExpoRegExp.Pattern = "<a\s+href=[""']?([^""'\s]+)[""']?\s*[^>]*>"'oRegExp.Pattern = "<a\s+href=[""']?(r[^""'\s]+)[""']?\s*[^>]*>"oRegExp.IgnoreCase = TRUEoRegExp.Global = TRUEset matches = oRegExp.Execute(sContent)然后是随机取其中一个RandomizenIndex = Int(matches.Count * RND())set oMatch = matches(nIndex)sPath = oMatch.SubMatches(0) 两个html页面的传值问题 初学,老师们,求求了 javascript权威指南的中文chm版本哪里有下载阿 onblur事件来触发验证的问题 关于如果延迟一个代码的执行 取不到<form>里面的元素的问题 右键菜单取消问题 哪里有javascript的命令、函数方面的资料呀?初学者求教! javascript的入门教程,请推荐一两本 实现类似confirm的对话框 请问各位高手用什么工具开发JSCRIPT网页呀? 请教一个问题。
to weidegong:最好是自动搜索。
<%Option Explicit%>
<%
DIM xmlhttp, matches,sURL,sHomeURL,sContent, oRegExp, oMatch, nIndex, nCount, sPath
sURL = "http://msdn.microsoft.com"
sHomeURL = "http://www.microsoft.com"set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET",sURL, FALSE
xmlhttp.SendsContent = xmlhttp.ResponseText
set oRegExp = new RegExp
oRegExp.Pattern = "<a\s+href=[""']?([^""'\s]+)[""']?\s*[^>]*>"
'oRegExp.Pattern = "<a\s+href=[""']?(r[^""'\s]+)[""']?\s*[^>]*>"
oRegExp.IgnoreCase = TRUE
oRegExp.Global = TRUE
set matches = oRegExp.Execute(sContent)
if matches.Count = 0 then
Response.Redirect sHomeURL
else
Randomize
nIndex = Int(matches.Count * RND())
set oMatch = matches(nIndex)
sPath = oMatch.SubMatches(0)
if Instr(sPath,"http://") = 0 then
if Left(sPath,1) = "/" then
sPath = sHomeURL & sPath
else
sPath = sHomeURL & "/" & sPath
end if
end if
Response.Redirect sPath
end if'nCount = 0
'for each oMatch in matches
' nCount = nCount + 1
'Response.Write "*****" & nCount & "*****<BR>"
'Response.Write oMatch.Value & "<BR>"
'Response.Write "href:" & oMatch.SubMatches(0) & "<BR>"
'Response.Write "**********<BR><BR>"
'next
%>
set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET",sURL, FALSE
xmlhttp.Send
sContent = xmlhttp.ResponseText然后是用正则表达式得出所有的连接,
set oRegExp = new RegExp
oRegExp.Pattern = "<a\s+href=[""']?([^""'\s]+)[""']?\s*[^>]*>"
'oRegExp.Pattern = "<a\s+href=[""']?(r[^""'\s]+)[""']?\s*[^>]*>"
oRegExp.IgnoreCase = TRUE
oRegExp.Global = TRUE
set matches = oRegExp.Execute(sContent)然后是随机取其中一个
Randomize
nIndex = Int(matches.Count * RND())
set oMatch = matches(nIndex)
sPath = oMatch.SubMatches(0)